From 3eb23ad9f07a807f97f147441f859157c509572c Mon Sep 17 00:00:00 2001 From: Pavel Durov Date: Sat, 25 Oct 2025 11:29:26 +0100 Subject: [PATCH] Restrict --file option to bench command. The --file option was previously defined as a global option, making it available for all subcommands (bench, diff, list). However, only the bench command actually uses the configuration file to run benchmarks. --- src/main.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 56bf64e..4fe8066 100644 --- a/src/main.rs +++ b/src/main.rs @@ -373,10 +373,6 @@ impl App { #[derive(Parser)] #[command(version, about, subcommand_required = true)] struct Cli { - /// Path to the haste configuration file (defaults to haste.toml). - #[arg(short = 'f', long, global = true, value_name = "FILE")] - file: Option, - #[command(subcommand)] mode: Mode, } @@ -386,6 +382,9 @@ enum Mode { /// Run benchmarks and store the results into a new datum. #[clap(visible_alias = "b")] Bench { + /// Path to the haste configuration file (defaults to haste.toml). + #[arg(short = 'f', long, value_name = "FILE")] + file: Option, /// Attach a comment to the datum. #[clap(short, long, num_args(1))] comment: Option, @@ -400,11 +399,19 @@ enum Mode { fn main() { let cli = Cli::parse(); - let app = App::new(cli.file); match cli.mode { - Mode::Bench { comment } => app.cmd_bench(comment), - Mode::Diff { id1, id2 } => app.cmd_diff(id1, id2), - Mode::List => app.cmd_list(), + Mode::Bench { file, comment } => { + let app = App::new(file); + app.cmd_bench(comment); + } + Mode::Diff { id1, id2 } => { + let app = App::new(None); + app.cmd_diff(id1, id2); + } + Mode::List => { + let app = App::new(None); + app.cmd_list(); + } } }