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

Remove duplicate function definition in cli module #747

Merged
merged 1 commit into from
Feb 6, 2025
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
2 changes: 1 addition & 1 deletion espflash/src/bin/espflash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct SaveImageArgs {
#[non_exhaustive]
struct WriteBinArgs {
/// Address at which to write the binary file
#[arg(value_parser = parse_uint32)]
#[arg(value_parser = parse_u32)]
pub addr: u32,
/// File containing the binary data to write
pub bin_file: String,
Expand Down
20 changes: 8 additions & 12 deletions espflash/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ pub struct EraseRegionArgs {
#[clap(flatten)]
pub connect_args: ConnectArgs,
/// Offset to start erasing from
#[arg(value_name = "OFFSET", value_parser = parse_uint32)]
#[arg(value_name = "OFFSET", value_parser = parse_u32)]
pub addr: u32,
/// Size of the region to erase
#[arg(value_name = "SIZE", value_parser = parse_uint32)]
#[arg(value_name = "SIZE", value_parser = parse_u32)]
pub size: u32,
}

Expand Down Expand Up @@ -190,24 +190,24 @@ pub struct PartitionTableArgs {
#[non_exhaustive]
pub struct ReadFlashArgs {
/// Offset to start reading from
#[arg(value_name = "OFFSET", value_parser = parse_uint32)]
#[arg(value_name = "OFFSET", value_parser = parse_u32)]
pub addr: u32,
/// Size of each individual packet of data
///
/// Defaults to 0x1000 (FLASH_SECTOR_SIZE)
#[arg(long, default_value = "0x1000", value_parser = parse_uint32)]
#[arg(long, default_value = "0x1000", value_parser = parse_u32)]
pub block_size: u32,
/// Connection configuration
#[clap(flatten)]
connect_args: ConnectArgs,
/// Size of the region to read
#[arg(value_name = "SIZE", value_parser = parse_uint32)]
#[arg(value_name = "SIZE", value_parser = parse_u32)]
pub size: u32,
/// Name of binary dump
#[arg(value_name = "FILE")]
pub file: PathBuf,
/// Maximum number of un-acked packets
#[arg(long, default_value = "64", value_parser = parse_uint32)]
#[arg(long, default_value = "64", value_parser = parse_u32)]
pub max_in_flight: u32,
}

Expand Down Expand Up @@ -245,7 +245,7 @@ pub struct ImageArgs {
#[arg(long, short = 'T', value_name = "FILE")]
pub partition_table: Option<PathBuf>,
/// Partition table offset
#[arg(long, value_name = "OFFSET", value_parser = parse_uint32)]
#[arg(long, value_name = "OFFSET", value_parser = parse_u32)]
pub partition_table_offset: Option<u32>,
/// Label of target app partition
#[arg(long, value_name = "LABEL")]
Expand Down Expand Up @@ -290,6 +290,7 @@ pub struct ChecksumMd5Args {
connect_args: ConnectArgs,
}

/// Parses an integer, in base-10 or hexadecimal format, into a [u32].
pub fn parse_u32(input: &str) -> Result<u32, ParseIntError> {
parse_int::parse(input)
}
Expand Down Expand Up @@ -809,11 +810,6 @@ fn pretty_print(table: PartitionTable) {
println!("{pretty}");
}

/// Parses a string as a 32-bit unsigned integer.
pub fn parse_uint32(input: &str) -> Result<u32, ParseIntError> {
parse_int::parse(input)
}

pub fn make_flash_settings(flash_config_args: &FlashConfigArgs, config: &Config) -> FlashSettings {
FlashSettings::new(
flash_config_args.flash_mode.or(config.flash.mode),
Expand Down