use genie::hki::HotkeyInfo;
use std::fs::File;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "Set Hotkey")]
struct SetHotkey {
#[structopt(name = "file-name")]
file_name: PathBuf,
#[structopt(name = "group-index")]
group_index: u32,
#[structopt(name = "hotkey-index")]
hotkey_index: u32,
#[structopt(name = "keycode")]
keycode: i32,
#[structopt(long = "ctrl", short = "c")]
ctrl: bool,
#[structopt(long = "alt", short = "a")]
alt: bool,
#[structopt(long = "shift", short = "s")]
shift: bool,
}
fn main() -> anyhow::Result<()> {
let cli_input = SetHotkey::from_args();
let mut f = File::open(&cli_input.file_name)?;
let info = HotkeyInfo::from(&mut f)?;
let info = info.bind_key(
cli_input.group_index as usize,
cli_input.hotkey_index as usize,
cli_input.keycode,
cli_input.ctrl,
cli_input.alt,
cli_input.shift,
)?;
let mut f = File::create(&cli_input.file_name)?;
info.write_to(&mut f)?;
Ok(())
}