Skip to content

Commit

Permalink
Add skip update check option
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Amiot committed Oct 17, 2024
1 parent 7b0c6ac commit 01a08e2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed `partition-table-offset` argument to accept offsets in hexadecimal (#682)
- espflash defmt log didn't display timestamp, according to [defmt doc](https://defmt.ferrous-systems.com/timestamps). (#680)
- Fixed pattern matching to detect download mode over multiple lines (#685)
- Add an option to prevent update checks (#689)

### Changed

Expand Down
15 changes: 12 additions & 3 deletions cargo-espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ enum CargoSubcommand {
Espflash {
#[clap(subcommand)]
subcommand: Commands,

#[clap(short, long, global = true, action)]
skip_update_check: bool,
},
}

Expand Down Expand Up @@ -203,13 +206,19 @@ fn main() -> Result<()> {

// Attempt to parse any provided comand-line arguments, or print the help
// message and terminate if the invocation is not correct.
let CargoSubcommand::Espflash { subcommand: args } = Cli::parse().subcommand;
debug!("{:#?}", args);
let cli = Cli::parse();
let CargoSubcommand::Espflash {
subcommand: args,
skip_update_check,
} = cli.subcommand;
debug!("{:#?}, {:#?}", args, skip_update_check);

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

// Load any user configuration, if present.
let config = Config::load()?;
Expand Down
12 changes: 9 additions & 3 deletions espflash/src/bin/espflash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ use miette::{IntoDiagnostic, Result, WrapErr};
pub struct Cli {
#[command(subcommand)]
subcommand: Commands,

#[clap(short, long, global = true, action)]
skip_update_check: bool,
}

#[derive(Debug, Subcommand)]
Expand Down Expand Up @@ -158,13 +161,16 @@ fn main() -> Result<()> {

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

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

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

0 comments on commit 01a08e2

Please sign in to comment.