Skip to content

Commit aa67776

Browse files
chore: remove codspeed use without argument in favor of codspeed show
1 parent a91cabc commit aa67776

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

src/cli/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub(crate) mod exec;
33
pub(crate) mod run;
44
mod setup;
55
mod shared;
6+
mod show;
67
mod use_mode;
78

89
pub(crate) use shared::*;
@@ -86,6 +87,8 @@ enum Commands {
8687
Setup,
8788
/// Set the codspeed mode for the rest of the shell session
8889
Use(use_mode::UseArgs),
90+
/// Show the codspeed mode previously set in this shell session with `codspeed use`
91+
Show,
8992
}
9093

9194
pub async fn run() -> Result<()> {
@@ -136,6 +139,7 @@ pub async fn run() -> Result<()> {
136139
Commands::Auth(args) => auth::run(args, &api_client, cli.config_name.as_deref()).await?,
137140
Commands::Setup => setup::setup(setup_cache_dir).await?,
138141
Commands::Use(args) => use_mode::run(args)?,
142+
Commands::Show => show::run()?,
139143
}
140144
Ok(())
141145
}

src/cli/show.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use crate::prelude::*;
2+
3+
pub fn run() -> Result<()> {
4+
let shell_session_mode = crate::runner_mode::load_shell_session_mode()?;
5+
6+
if let Some(mode) = shell_session_mode {
7+
info!("{mode:?}");
8+
} else {
9+
info!("No mode set for this shell session");
10+
}
11+
12+
Ok(())
13+
}

src/cli/use_mode.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,14 @@ use clap::Args;
88
pub struct UseArgs {
99
/// Set the CodSpeed runner mode for this shell session. If not provided, the current mode will
1010
/// be displayed.
11-
pub mode: Option<RunnerMode>,
11+
pub mode: RunnerMode,
1212
}
1313

1414
pub fn run(args: UseArgs) -> Result<()> {
15-
if let Some(mode) = &args.mode {
16-
crate::runner_mode::register_shell_session_mode(mode)?;
17-
debug!(
18-
"Registered codspeed use mode '{:?}' for this shell session (parent PID)",
19-
args.mode
20-
);
21-
} else {
22-
let shell_session_mode = crate::runner_mode::load_shell_session_mode()?;
23-
24-
if let Some(mode) = shell_session_mode {
25-
info!("{mode:?}");
26-
} else {
27-
info!("No mode set for this shell session");
28-
}
29-
}
15+
crate::runner_mode::register_shell_session_mode(&args.mode)?;
16+
debug!(
17+
"Registered codspeed use mode '{:?}' for this shell session (parent PID)",
18+
args.mode
19+
);
3020
Ok(())
3121
}

0 commit comments

Comments
 (0)