Skip to content

Commit 726f495

Browse files
ThrathraDavid-Amiotjessebraham
authored
Add skip update check option (#689)
* Add skip update check option * Add doc comments for `skip_update_check` --------- Co-authored-by: David Amiot <[email protected]> Co-authored-by: Jesse Braham <[email protected]>
1 parent 7b0c6ac commit 726f495

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Fixed `partition-table-offset` argument to accept offsets in hexadecimal (#682)
1717
- espflash defmt log didn't display timestamp, according to [defmt doc](https://defmt.ferrous-systems.com/timestamps). (#680)
1818
- Fixed pattern matching to detect download mode over multiple lines (#685)
19+
- Add an option to prevent update checks (#689)
1920

2021
### Changed
2122

cargo-espflash/src/main.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ enum CargoSubcommand {
5151
Espflash {
5252
#[clap(subcommand)]
5353
subcommand: Commands,
54+
55+
/// Do not check for updates
56+
#[clap(short, long, global = true, action)]
57+
skip_update_check: bool,
5458
},
5559
}
5660

@@ -203,13 +207,19 @@ fn main() -> Result<()> {
203207

204208
// Attempt to parse any provided comand-line arguments, or print the help
205209
// message and terminate if the invocation is not correct.
206-
let CargoSubcommand::Espflash { subcommand: args } = Cli::parse().subcommand;
207-
debug!("{:#?}", args);
210+
let cli = Cli::parse();
211+
let CargoSubcommand::Espflash {
212+
subcommand: args,
213+
skip_update_check,
214+
} = cli.subcommand;
215+
debug!("{:#?}, {:#?}", args, skip_update_check);
208216

209217
// Only check for updates once the command-line arguments have been processed,
210218
// to avoid printing any update notifications when the help message is
211219
// displayed.
212-
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
220+
if !skip_update_check {
221+
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
222+
}
213223

214224
// Load any user configuration, if present.
215225
let config = Config::load()?;

espflash/src/bin/espflash.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ use miette::{IntoDiagnostic, Result, WrapErr};
2828
pub struct Cli {
2929
#[command(subcommand)]
3030
subcommand: Commands,
31+
32+
/// Do not check for updates
33+
#[clap(short, long, global = true, action)]
34+
skip_update_check: bool,
3135
}
3236

3337
#[derive(Debug, Subcommand)]
@@ -158,13 +162,16 @@ fn main() -> Result<()> {
158162

159163
// Attempt to parse any provided comand-line arguments, or print the help
160164
// message and terminate if the invocation is not correct.
161-
let args = Cli::parse().subcommand;
162-
debug!("{:#?}", args);
165+
let cli = Cli::parse();
166+
let args = cli.subcommand;
167+
debug!("{:#?}, {:#?}", args, cli.skip_update_check);
163168

164169
// Only check for updates once the command-line arguments have been processed,
165170
// to avoid printing any update notifications when the help message is
166171
// displayed.
167-
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
172+
if !cli.skip_update_check {
173+
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
174+
}
168175

169176
// Load any user configuration, if present.
170177
let config = Config::load()?;

0 commit comments

Comments
 (0)