Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skip update check option #689

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 13 additions & 3 deletions cargo-espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ enum CargoSubcommand {
Espflash {
#[clap(subcommand)]
subcommand: Commands,

/// Do not check for updates
#[clap(short, long, global = true, action)]
skip_update_check: bool,
},
}

Expand Down Expand Up @@ -203,13 +207,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
13 changes: 10 additions & 3 deletions espflash/src/bin/espflash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ use miette::{IntoDiagnostic, Result, WrapErr};
pub struct Cli {
#[command(subcommand)]
subcommand: Commands,

/// Do not check for updates
#[clap(short, long, global = true, action)]
skip_update_check: bool,
}

#[derive(Debug, Subcommand)]
Expand Down Expand Up @@ -158,13 +162,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
Loading