Skip to content

Commit dfc9a28

Browse files
committed
implementing --auto-save arg
1 parent 002341b commit dfc9a28

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -eu
33

44
REPO="kavehtehrani/cloudflare-speed-cli"
55
BIN="cloudflare-speed-cli"
6-
PKG_NAME="cloudflare-speed-cli_"
6+
PKG_NAME="cloudflare-speed-cli"
77

88
echo "Fetching latest version..." >&2
99
VERSION="${VERSION:-$(curl -fsSL \

src/cli.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ pub struct Cli {
6161
#[arg(long)]
6262
pub experimental: bool,
6363

64-
/// Export full JSON result to a file
64+
/// Export results as JSON
6565
#[arg(long)]
6666
pub export_json: Option<std::path::PathBuf>,
6767

68-
/// Export a one-line CSV summary to a file
68+
/// Export results as CSV
6969
#[arg(long)]
7070
pub export_csv: Option<std::path::PathBuf>,
7171

72-
/// Automatically save test results (default: true)
73-
#[arg(long, default_value_t = true)]
72+
/// Use --auto-save true or --auto-save false to override (default: true)
73+
#[arg(long, default_value_t = true, action = clap::ArgAction::Set)]
7474
pub auto_save: bool,
7575

7676
/// Bind to a specific network interface (e.g., ens18, eth0)
@@ -150,8 +150,10 @@ async fn run_json(args: Cli) -> Result<()> {
150150
handle_exports(&args, &result)?;
151151

152152
println!("{}", serde_json::to_string_pretty(&result)?);
153-
if let Ok(p) = crate::storage::save_run(&result) {
154-
eprintln!("Saved: {}", p.display());
153+
if args.auto_save {
154+
if let Ok(p) = crate::storage::save_run(&result) {
155+
eprintln!("Saved: {}", p.display());
156+
}
155157
}
156158
Ok(())
157159
}
@@ -250,8 +252,10 @@ async fn run_text(args: Cli) -> Result<()> {
250252
exp.target
251253
);
252254
}
253-
if let Ok(p) = crate::storage::save_run(&result) {
254-
eprintln!("Saved: {}", p.display());
255+
if args.auto_save {
256+
if let Ok(p) = crate::storage::save_run(&result) {
257+
eprintln!("Saved: {}", p.display());
258+
}
255259
}
256260
Ok(())
257261
}

0 commit comments

Comments
 (0)