Skip to content

Commit

Permalink
Rename to --keycode
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Young <[email protected]>
  • Loading branch information
seanyoung committed May 20, 2024
1 parent f4c8131 commit 5c84324
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions cir/src/bin/cir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -305,7 +305,7 @@ struct Transmit {
#[arg(long = "file", short = 'f', name = "FILE", help_heading = "INPUT")]
files: Vec<OsString>,

/// Send scancode using old linux kernel protocols
/// Send scancode using linux kernel protocols
#[arg(
long = "scancode",
short = 'S',
Expand Down Expand Up @@ -358,7 +358,7 @@ struct Transmit {
remote: Option<String>,

/// 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<String>,

/// Set carrier in Hz, 0 for unmodulated
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
}

Expand Down
2 changes: 1 addition & 1 deletion cir/src/bin/commands/transmit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
12 changes: 6 additions & 6 deletions cir/tests/encode_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn encode_lircd_raw_test() {
"--dry-run",
"--keymap",
"../testdata/lircd_conf/pace/DC420N.lircd.conf",
"--code",
"--keycode",
"1",
])
.assert();
Expand Down Expand Up @@ -164,7 +164,7 @@ fn encode_lircd_grundig_test() {
"../testdata/lircd_conf/grundig/RP75_LCD.lircd.conf",
"-m",
"grundig_rp75",
"--code",
"--keycode",
"0",
])
.assert();
Expand Down Expand Up @@ -223,7 +223,7 @@ fn keymaps() {
"-v",
"--keymap",
"../testdata/rc_keymaps/RM-687C.toml",
"--code",
"--keycode",
"KEY_0",
])
.assert();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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",
])
Expand Down

0 comments on commit 5c84324

Please sign in to comment.