feat: register works

This commit is contained in:
2021-06-26 15:42:47 +08:00
parent 53371c5a18
commit c3a903173c
7 changed files with 589 additions and 14 deletions

View File

@@ -1,3 +1,30 @@
fn main() {
println!("Hello, world!");
}
#[macro_use] extern crate rust_util;
mod cmd;
mod register;
mod sign;
use clap::App;
use cmd::{Command, CommandError};
use cmd::DefaultCommandImpl;
fn main() -> CommandError {
let commands: Vec<Box<dyn Command>> = vec![
Box::new(register::CommandImpl),
Box::new(sign::CommandImpl),
];
let mut app = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.about(env!("CARGO_PKG_DESCRIPTION"));
app = DefaultCommandImpl::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);
}
}
DefaultCommandImpl::run(&matches)
}