This repository has been archived on 2024-09-05. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
hardownload/src/main.rs
2020-06-18 01:44:44 +08:00

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)
}