mirror of
https://git.um-react.app/um/lib_um_crypto_rust.git
synced 2026-03-08 04:29:54 +00:00
feat: allow override of buffer size
This commit is contained in:
@@ -6,22 +6,28 @@ use std::time::Instant;
|
||||
|
||||
mod cmd;
|
||||
|
||||
/// um_cli (rust ver.)
|
||||
/// A cli-tool to unlock encrypted audio files.
|
||||
#[derive(Parser)]
|
||||
#[command(name = "um_cli")]
|
||||
#[command(version = "0.1")]
|
||||
#[command(about = "um_cli (rust ver.)", long_about = None)]
|
||||
struct Cli {
|
||||
pub struct Cli {
|
||||
#[clap(subcommand)]
|
||||
command: Option<Commands>,
|
||||
|
||||
/// Time command
|
||||
/// Be more verbose about what is going on.
|
||||
#[clap(long, short, action=clap::ArgAction::SetTrue)]
|
||||
time: Option<bool>,
|
||||
verbose: Option<bool>,
|
||||
|
||||
/// Preferred buffer size when reading file, in bytes.
|
||||
/// Default to 4MiB.
|
||||
#[clap(long, short = 'B', default_value_t=4*1024*1024)]
|
||||
buffer_size: usize
|
||||
}
|
||||
|
||||
fn run_command(cli: &Cli) -> Result<i32> {
|
||||
match &cli.command {
|
||||
Some(Commands::QMCv1(cmd)) => cmd.run(),
|
||||
Some(Commands::QMCv1(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");
|
||||
@@ -37,7 +43,7 @@ fn main() {
|
||||
-1
|
||||
});
|
||||
let duration = start.elapsed();
|
||||
if let Some(true) = cli.time {
|
||||
if let Some(true) = cli.verbose {
|
||||
eprintln!("time: {:?}", duration);
|
||||
};
|
||||
exit(code);
|
||||
|
||||
Reference in New Issue
Block a user