From 5c843241ec488607886ce2d812bcb40177dd5615 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Mon, 20 May 2024 16:44:20 +0100 Subject: [PATCH] Rename to --keycode Signed-off-by: Sean Young --- README.md | 2 +- cir/src/bin/cir.rs | 21 +++++++++++---------- cir/src/bin/commands/transmit.rs | 2 +- cir/tests/encode_tests.rs | 12 ++++++------ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f192e3d..e5ebcf3 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ If you have a `.lircd.conf` file or `.toml` keymap, you can transmit with the fo command: ```bash -cir transmit --keymap RM-Y173.lircd.conf --code KEY_CHANNELUP +cir transmit --keymap RM-Y173.lircd.conf --keycode KEY_CHANNELUP ``` Alternatively, you can send raw IR directly like so: ```bash diff --git a/cir/src/bin/cir.rs b/cir/src/bin/cir.rs index 739ae65..cf33985 100644 --- a/cir/src/bin/cir.rs +++ b/cir/src/bin/cir.rs @@ -29,12 +29,12 @@ struct App { } enum Commands { - Decode(Decode), - Transmit(Transmit), #[cfg(target_os = "linux")] List(List), #[cfg(target_os = "linux")] Keymap(Keymap), + Decode(Decode), + Transmit(Transmit), #[cfg(target_os = "linux")] Test(Test), } @@ -167,13 +167,13 @@ struct List { device: RcDevice, /// Display the scancode to keycode mapping - #[arg(long = "read-mapping", short = 'm')] + #[arg(long = "read-mapping", short = 'r')] mapping: bool, } #[cfg(target_os = "linux")] fn parse_scankey(arg: &str) -> Result<(u64, String), String> { - if let Some((scancode, keycode)) = arg.split_once('=') { + if let Some((scancode, keycode)) = arg.split_once([':', '=']) { let scancode = if let Some(hex) = scancode.strip_prefix("0x") { u64::from_str_radix(hex, 16) } else { @@ -305,7 +305,7 @@ struct Transmit { #[arg(long = "file", short = 'f', name = "FILE", help_heading = "INPUT")] files: Vec, - /// Send scancode using old linux kernel protocols + /// Send scancode using linux kernel protocols #[arg( long = "scancode", short = 'S', @@ -358,7 +358,7 @@ struct Transmit { remote: Option, /// Code from keymap to send - #[arg(name = "CODES", long = "code", short = 'K', help_heading = "INPUT")] + #[arg(name = "CODE", long = "keycode", short = 'K', help_heading = "INPUT")] codes: Vec, /// Set carrier in Hz, 0 for unmodulated @@ -396,7 +396,7 @@ impl Transmit { arg!("FILE", OsString, File); arg!("RAWIR", String, RawIR); arg!("PRONTO", String, Pronto); - arg!("CODES", String, Code); + arg!("CODE", String, Code); arg!("IRP", String, Irp); arg!("GAP", u32, Gap); arg!("SCANCODE", String, Scancode); @@ -448,7 +448,7 @@ impl FromArgMatches for Commands { fn update_from_arg_matches(&mut self, matches: &ArgMatches) -> Result<(), Error> { match matches.subcommand() { Some(("decode", args)) => *self = Self::Decode(Decode::from_arg_matches(args)?), - Some(("rawir", args)) => { + Some(("transmit", args)) => { let mut tx = Transmit::from_arg_matches(args)?; tx.transmitables(args); @@ -530,8 +530,9 @@ impl Subcommand for Commands { cmd } - fn has_subcommand(name: &str) -> bool { - matches!(name, "irp" | "keymap" | "pronto" | "rawir") + + fn has_subcommand(_name: &str) -> bool { + false } } diff --git a/cir/src/bin/commands/transmit.rs b/cir/src/bin/commands/transmit.rs index 0564863..df72a28 100644 --- a/cir/src/bin/commands/transmit.rs +++ b/cir/src/bin/commands/transmit.rs @@ -314,7 +314,7 @@ fn encode_args(transmit: &crate::Transmit) -> Message { } } } else { - eprintln!("error: missing --keymap argument for --code"); + eprintln!("error: missing --keymap argument for --keycode"); std::process::exit(2); } } diff --git a/cir/tests/encode_tests.rs b/cir/tests/encode_tests.rs index d0dc00f..43a14aa 100644 --- a/cir/tests/encode_tests.rs +++ b/cir/tests/encode_tests.rs @@ -41,7 +41,7 @@ fn encode_lircd_raw_test() { "--dry-run", "--keymap", "../testdata/lircd_conf/pace/DC420N.lircd.conf", - "--code", + "--keycode", "1", ]) .assert(); @@ -164,7 +164,7 @@ fn encode_lircd_grundig_test() { "../testdata/lircd_conf/grundig/RP75_LCD.lircd.conf", "-m", "grundig_rp75", - "--code", + "--keycode", "0", ]) .assert(); @@ -223,7 +223,7 @@ fn keymaps() { "-v", "--keymap", "../testdata/rc_keymaps/RM-687C.toml", - "--code", + "--keycode", "KEY_0", ]) .assert(); @@ -277,7 +277,7 @@ info: rawir: +2369 -637 +1166 -637 +565 -637 +565 -637 +1166 -637 +565 -637 +565 "--dry-run", "--keymap", "foo.toml", - "--code", + "--keycode", "KEY_CABLEFWD", ]) .assert(); @@ -303,7 +303,7 @@ info: rawir: +2369 -637 +1166 -637 +565 -637 +565 -637 +1166 -637 +565 -637 +565 "--dry-run", "--keymap", "Cargo.toml", - "--code", + "--keycode", "KEY_CABLEFWD", ]) .assert(); @@ -329,7 +329,7 @@ info: rawir: +2369 -637 +1166 -637 +565 -637 +565 -637 +1166 -637 +565 -637 +565 "--dry-run", "--keymap", "../testdata/rc_keymaps/rc6_mce.toml", - "--code", + "--keycode", "KEY_ENTER", "-v", ])