Skip to content

Commit

Permalink
💄 zx: support --help and -h
Browse files Browse the repository at this point in the history
Best. Feature. Ever!
  • Loading branch information
whot committed Aug 24, 2023
1 parent 6b81f08 commit d026e31
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions zbus_xmlgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ use zbus_xml::{Interface, Node};
use zbus_xmlgen::GenTrait;
use zvariant::ObjectPath;

fn usage() {
eprintln!(
r#"Usage:
zbus-xmlgen <interface.xml>
zbus-xmlgen --system|--session <service> <object_path>
zbus-xmlgen --address <address> <service> <object_path>
"#
);
}

fn main() -> Result<(), Box<dyn Error>> {
let input_src;

Expand Down Expand Up @@ -84,6 +94,10 @@ fn main() -> Result<(), Box<dyn Error>> {
Some(path),
)
}
Some(help) if help == "--help" || help == "-h" => {
usage();
return Ok(());
}
Some(path) => {
input_src = Path::new(&path)
.file_name()
Expand All @@ -94,13 +108,7 @@ fn main() -> Result<(), Box<dyn Error>> {
(Node::from_reader(f)?, None, None)
}
None => {
eprintln!(
r#"Usage:
zbus-xmlgen <interface.xml>
zbus-xmlgen --system|--session <service> <object_path>
zbus-xmlgen --address <address> <service> <object_path>
"#
);
usage();
return Ok(());
}
};
Expand Down

0 comments on commit d026e31

Please sign in to comment.