Skip to content

Commit

Permalink
Upgrade clap to 3.2.5
Browse files Browse the repository at this point in the history
Clap 3.2 is the last release before 4.0:
https://epage.github.io/blog/2022/06/clap-32-last-call-before-40/

These changes upgrade our usage of features that are being deprecated,
insuring that we shall have an easy upgrade path to 4.0.

The two biggest changes:

1. removing NoAutoVersion.
2. changing our usage of parse_int::parse to the new value_parser API

Big thanks to @epage for helping out with 2:
clap-rs/clap#3839

And for working through some error messages:
clap-rs/clap#3822

As for NoAutoVersion, opting into the new behavior via `action` does
what we want, *except* that the output for doing it with another
incorrect flag doesn't give the error about how that's incorrect. I
suspect that this is an acceptable change in behavior, but worth calling
out. You can see the difference in the chip.trycmd tests.
  • Loading branch information
steveklabnik committed Jun 16, 2022
1 parent 5b9738c commit 1a171e1
Show file tree
Hide file tree
Showing 28 changed files with 68 additions and 65 deletions.
28 changes: 17 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -114,7 +114,7 @@ fallible-iterator = "0.2.0"
log = {version = "0.4.8", features = ["std"]}
env_logger = "0.9.0"
bitfield = "0.13.2"
clap = "3.0.12"
clap = "3.2.5"
csv = "1.1.3"
serde = "1.0.126"
parse_int = "0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion cmd/dashboard/src/lib.rs
Expand Up @@ -51,7 +51,7 @@ struct DashboardArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
2 changes: 1 addition & 1 deletion cmd/diagnose/src/lib.rs
Expand Up @@ -46,7 +46,7 @@ struct DiagnoseArgs {
/// timeout to wait for interactions with the supervisor task to complete
#[clap(
long, short, default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
5 changes: 3 additions & 2 deletions cmd/etm/src/lib.rs
Expand Up @@ -34,7 +34,8 @@ struct EtmArgs {
/// sets ETM trace identifier
#[clap(
long, short, value_name = "identifier",
default_value = "0x54", parse(try_from_str = parse_int::parse),
default_value = "0x54",
value_parser=parse_int::parse::<u8>,
)]
traceid: u8,
/// ingest ETM data as CSV
Expand All @@ -46,7 +47,7 @@ struct EtmArgs {
/// sets the value of SWOSCALER
#[clap(
long, short, value_name = "scaler", requires = "enable",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u16>,
)]
clockscaler: Option<u16>,
/// output ETM data as CSV
Expand Down
2 changes: 1 addition & 1 deletion cmd/gpio/src/lib.rs
Expand Up @@ -111,7 +111,7 @@ struct GpioArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
2 changes: 1 addition & 1 deletion cmd/hash/src/lib.rs
Expand Up @@ -92,7 +92,7 @@ struct HashArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
2 changes: 1 addition & 1 deletion cmd/hiffy/src/lib.rs
Expand Up @@ -58,7 +58,7 @@ struct HiffyArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
8 changes: 4 additions & 4 deletions cmd/i2c/src/lib.rs
Expand Up @@ -115,7 +115,7 @@ pub struct I2cArgs {
/// sets timeout
#[clap(
long, short, default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand All @@ -128,7 +128,7 @@ pub struct I2cArgs {
/// have side-effects on unsporting devices
#[clap(long, short = 'S', value_name = "register",
conflicts_with_all = &["scan", "register", "device"],
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<u8>,
)]
scanreg: Option<u8>,

Expand Down Expand Up @@ -156,7 +156,7 @@ pub struct I2cArgs {

/// specifies register
#[clap(long, short, value_name = "register",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<u8>,
)]
register: Option<u8>,

Expand Down Expand Up @@ -184,7 +184,7 @@ pub struct I2cArgs {
/// number of bytes to read from (or write to) register
#[clap(long, short, value_name = "nbytes",
conflicts_with = "write",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<u8>,
)]
nbytes: Option<u8>,

Expand Down
4 changes: 2 additions & 2 deletions cmd/itm/src/lib.rs
Expand Up @@ -67,7 +67,7 @@ struct ItmArgs {
/// sets ITM trace identifier
#[clap(
long, short, default_value = "0x3a", value_name = "identifier",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u8>,
)]
traceid: u8,
/// ingest ITM data as CSV
Expand All @@ -81,7 +81,7 @@ struct ItmArgs {
bypass: bool,
/// sets the value of SWOSCALER
#[clap(long, short, value_name = "scaler", requires = "enable",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<u16>,
)]
clockscaler: Option<u16>,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/jefe/src/lib.rs
Expand Up @@ -96,7 +96,7 @@ struct JefeArgs {
/// sets timeout
#[clap(
long, short, default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
2 changes: 1 addition & 1 deletion cmd/lpc55gpio/src/lib.rs
Expand Up @@ -21,7 +21,7 @@ struct GpioArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
2 changes: 1 addition & 1 deletion cmd/pmbus/Cargo.toml
Expand Up @@ -9,7 +9,7 @@ humility = { path = "../../humility-core", package = "humility-core" }
humility-cmd = { path = "../../humility-cmd" }
hif = { git = "https://github.com/oxidecomputer/hif" }
pmbus = { git = "https://github.com/oxidecomputer/pmbus" }
clap = { version = "3.0.12", features = ["derive", "env"] }
clap = { version = "3.2.5", features = ["derive", "env"] }
anyhow = { version = "1.0.44", features = ["backtrace"] }
colored = "2.0.0"
indexmap = { version = "1.7", features = ["serde-1"] }
Expand Down
4 changes: 2 additions & 2 deletions cmd/pmbus/src/lib.rs
Expand Up @@ -25,7 +25,7 @@ struct PmbusArgs {
/// sets timeout
#[clap(
long, short, default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down Expand Up @@ -82,7 +82,7 @@ struct PmbusArgs {

/// specifies an I2C controller
#[clap(long, short, value_name = "controller",
parse(try_from_str = parse_int::parse),
value_parser = parse_int::parse::<u8>
)]
controller: Option<u8>,

Expand Down
6 changes: 3 additions & 3 deletions cmd/qspi/src/lib.rs
Expand Up @@ -107,7 +107,7 @@ struct QspiArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down Expand Up @@ -144,13 +144,13 @@ struct QspiArgs {

/// specify flash address in bytes
#[clap(long, short, value_name = "address",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<usize>,
)]
addr: Option<usize>,

/// specify size in bytes
#[clap(long, short, value_name = "nbytes",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<usize>,
)]
nbytes: Option<usize>,

Expand Down
2 changes: 1 addition & 1 deletion cmd/readmem/src/lib.rs
Expand Up @@ -138,7 +138,7 @@ struct ReadmemArgs {
address: String,

/// length to read
#[clap(parse(try_from_str = parse_int::parse))]
#[clap(value_parser=parse_int::parse::<usize>)]
length: Option<usize>,
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/rencm/src/lib.rs
Expand Up @@ -34,7 +34,7 @@ struct RencmArgs {
/// sets timeout
#[clap(
long, short, default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand All @@ -50,7 +50,7 @@ struct RencmArgs {

/// specifies an I2C controller
#[clap(long, short, value_name = "controller",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<u8>,
)]
controller: Option<u8>,

Expand Down
4 changes: 2 additions & 2 deletions cmd/rendmp/src/lib.rs
Expand Up @@ -25,7 +25,7 @@ struct RendmpArgs {
/// sets timeout
#[clap(
long, short, default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand All @@ -37,7 +37,7 @@ struct RendmpArgs {

/// specifies an I2C controller
#[clap(long, short, value_name = "controller",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<u8>,
)]
controller: Option<u8>,

Expand Down
2 changes: 1 addition & 1 deletion cmd/sensors/src/lib.rs
Expand Up @@ -37,7 +37,7 @@ struct SensorsArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
6 changes: 3 additions & 3 deletions cmd/spctrl/src/lib.rs
Expand Up @@ -60,12 +60,12 @@ use hif::*;
#[clap(name = "subcmd")]
enum SpCtrlCmd {
Write {
#[clap(parse(try_from_str = parse_int::parse))]
#[clap(value_parser=parse_int::parse::<u32>)]
addr: u32,
bytes: String,
},
Read {
#[clap(parse(try_from_str = parse_int::parse))]
#[clap(value_parser=parse_int::parse::<u32>)]
addr: u32,
nbytes: usize,
},
Expand All @@ -78,7 +78,7 @@ struct SpCtrlArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand Down
4 changes: 2 additions & 2 deletions cmd/spd/src/lib.rs
Expand Up @@ -20,7 +20,7 @@ struct SpdArgs {
/// sets timeout
#[clap(
long, short, default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand All @@ -30,7 +30,7 @@ struct SpdArgs {

/// specifies an I2C controller
#[clap(long, short, value_name = "controller",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<u8>,
)]
controller: Option<u8>,

Expand Down
4 changes: 2 additions & 2 deletions cmd/spi/src/lib.rs
Expand Up @@ -50,7 +50,7 @@ struct SpiArgs {
/// sets timeout
#[clap(
long, short = 'T', default_value = "5000", value_name = "timeout_ms",
parse(try_from_str = parse_int::parse)
value_parser=parse_int::parse::<u32>,
)]
timeout: u32,

Expand All @@ -68,7 +68,7 @@ struct SpiArgs {

/// specify number of bytes to read
#[clap(long, short, value_name = "nbytes",
parse(try_from_str = parse_int::parse),
value_parser=parse_int::parse::<usize>,
)]
nbytes: Option<usize>,

Expand Down
4 changes: 2 additions & 2 deletions cmd/stmsecure/src/lib.rs
Expand Up @@ -71,9 +71,9 @@ enum StmSecureArgs {
/// region before this is programmed otherwise you will brick the device
/// !!!
SetSecureRegion {
#[clap(parse(try_from_str = parse_int::parse))]
#[clap(value_parser=parse_int::parse::<u32>)]
address: u32,
#[clap(parse(try_from_str = parse_int::parse))]
#[clap(value_parser=parse_int::parse::<u32>)]
size: u32,
#[clap(long)]
doit: bool,
Expand Down

0 comments on commit 1a171e1

Please sign in to comment.