init commit

This commit is contained in:
2020-06-17 08:21:04 +08:00
parent f81ec4a117
commit c58d9a8770
8 changed files with 1305 additions and 4 deletions

32
src/main.rs Normal file
View 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)
}