Skip to content

Commit 4be2e55

Browse files
AdamGSart049
authored andcommitted
feat: support for --locked, --frozen and --offline in the build command
1 parent 97babdc commit 4be2e55

File tree

1 file changed

+27
-4
lines changed
  • crates/cargo-codspeed/src

1 file changed

+27
-4
lines changed

crates/cargo-codspeed/src/app.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ pub(crate) struct BenchTargetFilters {
4242
pub(crate) bench: Option<Vec<String>>,
4343
}
4444

45+
// Help headings, should mostly match the headers from cargo build --help
4546
const FEATURE_HELP: &str = "Feature Selection";
4647
const COMPILATION_HELP: &str = "Compilation Options";
4748
const TARGET_HELP: &str = "Target Selection";
49+
const MANIFEST_HELP: &str = "Manifest Options";
50+
4851
#[derive(Subcommand)]
4952
enum Commands {
5053
/// Build the benchmarks
@@ -72,6 +75,18 @@ enum Commands {
7275
#[arg(long, default_value = "bench", help_heading = COMPILATION_HELP)]
7376
profile: String,
7477

78+
/// Assert that `Cargo.lock` will remain unchanged
79+
#[arg(long, help_heading = MANIFEST_HELP)]
80+
locked: bool,
81+
82+
/// Run without accessing the network
83+
#[arg(long, help_heading = MANIFEST_HELP)]
84+
offline: bool,
85+
86+
/// Equivalent to specifying both --locked and --offline
87+
#[arg(long, help_heading = MANIFEST_HELP)]
88+
frozen: bool,
89+
7590
#[command(flatten)]
7691
bench_target_filters: BenchTargetFilters,
7792
},
@@ -104,22 +119,30 @@ pub fn run(args: impl Iterator<Item = OsString>) -> Result<()> {
104119
jobs,
105120
no_default_features,
106121
profile,
122+
locked,
123+
offline,
124+
frozen,
107125
} => {
108126
let passthrough_flags = {
109127
let mut passthrough_flags = Vec::new();
110-
111128
if all_features {
112129
passthrough_flags.push("--all-features".to_string());
113130
}
114-
115131
if no_default_features {
116132
passthrough_flags.push("--no-default-features".to_string());
117133
}
118-
134+
if locked {
135+
passthrough_flags.push("--locked".to_string());
136+
}
137+
if offline {
138+
passthrough_flags.push("--offline".to_string());
139+
}
140+
if frozen {
141+
passthrough_flags.push("--frozen".to_string());
142+
}
119143
if let Some(jobs) = jobs {
120144
passthrough_flags.push(format!("--jobs={jobs}"));
121145
}
122-
123146
passthrough_flags
124147
};
125148
let features =

0 commit comments

Comments
 (0)