Skip to content

Commit

Permalink
migrate to Clap 4
Browse files Browse the repository at this point in the history
Summary:
Two `below` crates currently still use Clap 3; update to 4.

This unblocks updating below in Fedora which has dropped clap 3 from its repos.

Reviewed By: brianc118

Differential Revision: D48002223

fbshipit-source-id: 5f4d02fced4f182098b3ee7627b0af3179d9addb
  • Loading branch information
michel-slm authored and facebook-github-bot committed Aug 2, 2023
1 parent a9c7e29 commit a1b257d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions below/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ unit-scripts = "../etc"
[dependencies]
anyhow = "1.0.71"
cgroupfs = { version = "0.7.1", path = "cgroupfs" }
clap = { version = "3.2.25", features = ["derive", "env", "regex", "unicode", "wrap_help"] }
clap_complete = "3.2.5"
clap = { version = "4.3.5", features = ["derive", "env", "string", "unicode", "wrap_help"] }
clap_complete = "4.3.1"
common = { package = "below-common", version = "0.7.1", path = "common" }
config = { package = "below-config", version = "0.7.1", path = "config" }
cursive = { version = "0.20.0", features = ["crossterm-backend"], default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion below/dump/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "Apache-2.0"
[dependencies]
anyhow = "1.0.71"
below_derive = { version = "0.7.1", path = "../below_derive" }
clap = { version = "3.2.25", features = ["derive", "env", "regex", "unicode", "wrap_help"] }
clap = { version = "4.3.5", features = ["derive", "env", "string", "unicode", "wrap_help"] }
common = { package = "below-common", version = "0.7.1", path = "../common" }
model = { package = "below-model", version = "0.7.1", path = "../model" }
once_cell = "1.12"
Expand Down
14 changes: 7 additions & 7 deletions below/dump/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ pub enum DumpCommand {
#[clap(about = SYSTEM_ABOUT, long_about = SYSTEM_LONG_ABOUT.as_str())]
System {
/// Select which fields to display and in what order.
#[clap(short, long, multiple_values = true)]
#[clap(short, long, num_args = 1..)]
fields: Option<Vec<SystemOptionField>>,
#[clap(flatten)]
opts: GeneralOpt,
Expand All @@ -1056,7 +1056,7 @@ pub enum DumpCommand {
#[clap(about = DISK_ABOUT, long_about = DISK_LONG_ABOUT.as_str())]
Disk {
/// Select which fields to display and in what order.
#[clap(short, long, multiple_values = true)]
#[clap(short, long, num_args = 1..)]
fields: Option<Vec<DiskOptionField>>,
#[clap(flatten)]
opts: GeneralOpt,
Expand Down Expand Up @@ -1084,7 +1084,7 @@ pub enum DumpCommand {
#[clap(about = PROCESS_ABOUT, long_about = PROCESS_LONG_ABOUT.as_str())]
Process {
/// Select which fields to display and in what order.
#[clap(short, long, multiple_values = true)]
#[clap(short, long, num_args = 1..)]
fields: Option<Vec<ProcessOptionField>>,
#[clap(flatten)]
opts: GeneralOpt,
Expand All @@ -1098,7 +1098,7 @@ pub enum DumpCommand {
#[clap(about = CGROUP_ABOUT, long_about = CGROUP_LONG_ABOUT.as_str())]
Cgroup {
/// Select which fields to display and in what order.
#[clap(short, long, multiple_values = true)]
#[clap(short, long, num_args = 1..)]
fields: Option<Vec<CgroupOptionField>>,
#[clap(flatten)]
opts: GeneralOpt,
Expand All @@ -1112,7 +1112,7 @@ pub enum DumpCommand {
#[clap(about = IFACE_ABOUT, long_about = IFACE_LONG_ABOUT.as_str())]
Iface {
/// Select which fields to display and in what order.
#[clap(short, long, multiple_values = true)]
#[clap(short, long, num_args = 1..)]
fields: Option<Vec<IfaceOptionField>>,
#[clap(flatten)]
opts: GeneralOpt,
Expand All @@ -1126,7 +1126,7 @@ pub enum DumpCommand {
#[clap(about = NETWORK_ABOUT, long_about = NETWORK_LONG_ABOUT.as_str())]
Network {
/// Select which fields to display and in what order.
#[clap(short, long, multiple_values = true)]
#[clap(short, long, num_args = 1..)]
fields: Option<Vec<NetworkOptionField>>,
#[clap(flatten)]
opts: GeneralOpt,
Expand All @@ -1137,7 +1137,7 @@ pub enum DumpCommand {
#[clap(about = TRANSPORT_ABOUT, long_about = TRANSPORT_LONG_ABOUT.as_str())]
Transport {
/// Select which fields to display and in what order.
#[clap(short, long, multiple_values = true)]
#[clap(short, long, num_args = 1..)]
fields: Option<Vec<TransportOptionField>>,
#[clap(flatten)]
opts: GeneralOpt,
Expand Down
8 changes: 4 additions & 4 deletions below/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static LIVE_REMOTE_MAX_LATENCY_SEC: u64 = 10;

#[derive(Debug, Parser)]
struct Opt {
#[clap(long, parse(from_os_str), default_value = config::BELOW_DEFAULT_CONF)]
#[clap(long, value_parser, default_value = config::BELOW_DEFAULT_CONF)]
config: PathBuf,
#[clap(short, long)]
debug: bool,
Expand All @@ -104,7 +104,7 @@ struct CompressOpts {
///
/// With --dict-compress-chunk-size 16, you can expect around
/// 20-30x smaller data files.
#[clap(long, requires("compress"), parse(try_from_str = parse_chunk_size))]
#[clap(long, requires("compress"), value_parser = parse_chunk_size)]
dict_compress_chunk_size: Option<u32>,
}

Expand Down Expand Up @@ -267,7 +267,7 @@ enum Command {
duration: Option<String>,
/// Output file path.
/// Randomized name in current directory if unspecified.
#[clap(short, long, parse(from_os_str))]
#[clap(short, long, value_parser)]
output: Option<PathBuf>,
/// Supply hostname to take snapshot from remote
#[clap(short = 's', long)]
Expand All @@ -283,7 +283,7 @@ enum Command {
#[clap(short, long, default_value = "bash")]
shell: Shell,
/// Output file, stdout if not present
#[clap(short, long, parse(from_os_str))]
#[clap(short, long, value_parser)]
output: Option<PathBuf>,
},
}
Expand Down

0 comments on commit a1b257d

Please sign in to comment.