From aa6777621a1581c9f58316b3a8b868470f7e542d Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Wed, 28 Jan 2026 09:59:51 +0100 Subject: [PATCH] chore: remove `codspeed use` without argument in favor of `codspeed show` --- src/cli/mod.rs | 4 ++++ src/cli/show.rs | 13 +++++++++++++ src/cli/use_mode.rs | 22 ++++++---------------- 3 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 src/cli/show.rs diff --git a/src/cli/mod.rs b/src/cli/mod.rs index df313b13..e2f9b60f 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -3,6 +3,7 @@ pub(crate) mod exec; pub(crate) mod run; mod setup; mod shared; +mod show; mod use_mode; pub(crate) use shared::*; @@ -86,6 +87,8 @@ enum Commands { Setup, /// Set the codspeed mode for the rest of the shell session Use(use_mode::UseArgs), + /// Show the codspeed mode previously set in this shell session with `codspeed use` + Show, } pub async fn run() -> Result<()> { @@ -136,6 +139,7 @@ pub async fn run() -> Result<()> { Commands::Auth(args) => auth::run(args, &api_client, cli.config_name.as_deref()).await?, Commands::Setup => setup::setup(setup_cache_dir).await?, Commands::Use(args) => use_mode::run(args)?, + Commands::Show => show::run()?, } Ok(()) } diff --git a/src/cli/show.rs b/src/cli/show.rs new file mode 100644 index 00000000..41aa8173 --- /dev/null +++ b/src/cli/show.rs @@ -0,0 +1,13 @@ +use crate::prelude::*; + +pub fn run() -> Result<()> { + let shell_session_mode = crate::runner_mode::load_shell_session_mode()?; + + if let Some(mode) = shell_session_mode { + info!("{mode:?}"); + } else { + info!("No mode set for this shell session"); + } + + Ok(()) +} diff --git a/src/cli/use_mode.rs b/src/cli/use_mode.rs index af0d75fc..a08d79af 100644 --- a/src/cli/use_mode.rs +++ b/src/cli/use_mode.rs @@ -8,24 +8,14 @@ use clap::Args; pub struct UseArgs { /// Set the CodSpeed runner mode for this shell session. If not provided, the current mode will /// be displayed. - pub mode: Option, + pub mode: RunnerMode, } pub fn run(args: UseArgs) -> Result<()> { - if let Some(mode) = &args.mode { - crate::runner_mode::register_shell_session_mode(mode)?; - debug!( - "Registered codspeed use mode '{:?}' for this shell session (parent PID)", - args.mode - ); - } else { - let shell_session_mode = crate::runner_mode::load_shell_session_mode()?; - - if let Some(mode) = shell_session_mode { - info!("{mode:?}"); - } else { - info!("No mode set for this shell session"); - } - } + crate::runner_mode::register_shell_session_mode(&args.mode)?; + debug!( + "Registered codspeed use mode '{:?}' for this shell session (parent PID)", + args.mode + ); Ok(()) }