Files
simple-rust-tests/__crypto/simple_contract/src/main.rs
2021-01-01 22:16:11 +08:00

43 lines
1.2 KiB
Rust

pub mod util;
pub mod tx;
pub mod credit;
pub mod engine;
pub mod engine_credit;
mod cmd;
mod cmd_default;
mod cmd_genkey;
mod cmd_credit_create;
mod cmd_credit_issue;
mod cmd_credit_transfer;
mod cmd_credit_query;
mod cmd_credit_queryall;
use clap::App;
use cmd::{Command, CommandError};
fn main() -> CommandError {
let commands: Vec<Box<dyn Command>> = vec![
Box::new(cmd_genkey::CommandImpl),
Box::new(cmd_credit_create::CommandImpl),
Box::new(cmd_credit_issue::CommandImpl),
Box::new(cmd_credit_transfer::CommandImpl),
Box::new(cmd_credit_query::CommandImpl),
Box::new(cmd_credit_queryall::CommandImpl),
];
let mut app = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.about(env!("CARGO_PKG_DESCRIPTION"));
app = cmd_default::CommandImpl::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);
}
}
cmd_default::CommandImpl::run(&matches)
}