File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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" ) ]
424425struct 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
You can’t perform that action at this time.
0 commit comments