init commit
This commit is contained in:
32
src/main.rs
Normal file
32
src/main.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use clap::App;
|
||||
|
||||
mod cmd;
|
||||
mod cmd_sample;
|
||||
mod cmd_default;
|
||||
mod har;
|
||||
|
||||
use cmd::{ Command, CommandError, };
|
||||
use cmd_sample::CommandSample;
|
||||
use cmd_default::CommandDefault;
|
||||
|
||||
fn main() -> CommandError {
|
||||
let commands = vec![
|
||||
CommandSample{},
|
||||
];
|
||||
let mut app = App::new(env!("CARGO_PKG_NAME"))
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.about(env!("CARGO_PKG_DESCRIPTION"));
|
||||
app = CommandDefault::process_command(app);
|
||||
for command in &commands {
|
||||
app = app.subcommand(command.subcommand());
|
||||
}
|
||||
|
||||
let matches = app.get_matches();
|
||||
for command in &commands {
|
||||
if let Some(sub_cmd_matches) = matches.subcommand_matches(command.name()) {
|
||||
return command.run(&matches, sub_cmd_matches);
|
||||
}
|
||||
}
|
||||
|
||||
CommandDefault::run(&matches)
|
||||
}
|
||||
Reference in New Issue
Block a user