feat: register works
This commit is contained in:
33
src/main.rs
33
src/main.rs
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user