Skip to content

Commit 9c253e5

Browse files
authored
feat: add version subcommand to CLI (#26)
1 parent 61b9f6e commit 9c253e5

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

crates/ranma-cli/src/main.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum Command {
2323
Query(QueryCmd),
2424
Displays(DisplaysCmd),
2525
Tree(TreeCmd),
26+
Version(VersionCmd),
2627
}
2728

2829
/// start the ranma server
@@ -423,6 +424,11 @@ struct QueryCmd {
423424
#[argh(subcommand, name = "displays")]
424425
struct DisplaysCmd {}
425426

427+
/// print version
428+
#[derive(FromArgs)]
429+
#[argh(subcommand, name = "version")]
430+
struct VersionCmd {}
431+
426432
/// display node tree
427433
#[derive(FromArgs)]
428434
#[argh(subcommand, name = "tree")]
@@ -440,6 +446,11 @@ fn main() {
440446
return;
441447
}
442448

449+
if let Command::Version(_) = args.command {
450+
println!("v{}", env!("CARGO_PKG_VERSION"));
451+
return;
452+
}
453+
443454
if let Command::Tree(cmd) = args.command {
444455
run_tree(cmd);
445456
return;
@@ -749,7 +760,7 @@ fn build_command(cmd: Command) -> Value {
749760
Command::Remove(c) => json!({ "command": "remove", "name": c.name }),
750761
Command::Query(c) => json!({ "command": "query", "name": c.name, "display": c.display }),
751762
Command::Displays(_) => json!({ "command": "displays" }),
752-
Command::Tree(_) => unreachable!(),
763+
Command::Tree(_) | Command::Version(_) => unreachable!(),
753764
}
754765
}
755766

0 commit comments

Comments
 (0)