33 lines
864 B
Rust
33 lines
864 B
Rust
use clap::App;
|
|
|
|
mod cmd;
|
|
mod cmd_download;
|
|
mod cmd_default;
|
|
mod har;
|
|
|
|
use cmd::{ Command, CommandError, };
|
|
use cmd_download::CommandDownload;
|
|
use cmd_default::CommandDefault;
|
|
|
|
fn main() -> CommandError {
|
|
let commands: Vec<Box<dyn Command>> = vec![
|
|
Box::new(CommandDownload{}),
|
|
];
|
|
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)
|
|
}
|