feat: add qmc2 cli

This commit is contained in:
鲁树人
2024-09-06 00:52:23 +01:00
parent a9c7ba9fd4
commit e6fcb07ed2
4 changed files with 99 additions and 3 deletions

View File

@@ -16,8 +16,8 @@ pub struct Cli {
command: Option<Commands>,
/// Be more verbose about what is going on.
#[clap(long, short, action=clap::ArgAction::SetTrue)]
verbose: Option<bool>,
#[clap(long, short, action=clap::ArgAction::SetTrue, default_value_t=false)]
verbose: bool,
/// Preferred buffer size when reading file, in bytes.
/// Default to 4MiB.
@@ -28,6 +28,7 @@ pub struct Cli {
fn run_command(cli: &Cli) -> Result<i32> {
match &cli.command {
Some(Commands::QMCv1(cmd)) => cmd.run(&cli),
Some(Commands::QMCv2(cmd)) => cmd.run(&cli),
None => {
// https://github.com/clap-rs/clap/issues/3857#issuecomment-1161796261
todo!("implement a sensible default command, similar to um/cli");
@@ -43,7 +44,7 @@ fn main() {
-1
});
let duration = start.elapsed();
if let Some(true) = cli.verbose {
if cli.verbose {
eprintln!("time: {:?}", duration);
};
exit(code);