-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #505 from FineFindus/feat/zx-args-parser
zx: use clap for arg parsing
- Loading branch information
Showing
3 changed files
with
128 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::path::PathBuf; | ||
|
||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
pub struct Args { | ||
#[clap(subcommand)] | ||
pub command: Command, | ||
|
||
/// Specify the destination for saving the output. If no argument is provided, the parsed | ||
/// interfaces will be stored in separate files. If a filename is provided, the output will | ||
/// be saved to that file. Use '-' to print the output to stdout. | ||
#[clap(short, long, allow_hyphen_values = true, global = true)] | ||
pub output: Option<String>, | ||
} | ||
|
||
#[derive(Parser, Debug, Clone)] | ||
pub enum Command { | ||
/// Generate code for interfaces in the specified file. | ||
#[clap()] | ||
File { path: PathBuf }, | ||
|
||
/// Generate code for interfaces from the specified system service. | ||
#[clap()] | ||
System { | ||
service: String, | ||
object_path: String, | ||
}, | ||
|
||
/// Generate code for interfaces from the current users session. | ||
#[clap()] | ||
Session { | ||
service: String, | ||
object_path: String, | ||
}, | ||
|
||
/// Generate code for interfaces from the specified address. | ||
#[clap()] | ||
Address { | ||
address: String, | ||
service: String, | ||
object_path: String, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters