Skip to content

Commit 6f5df2b

Browse files
Update clap to v4
1 parent 4e7cc80 commit 6f5df2b

File tree

11 files changed

+78
-99
lines changed

11 files changed

+78
-99
lines changed

Cargo.lock

Lines changed: 7 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

collector/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
description = "Collects Rust performance data"
77

88
[dependencies]
9-
clap = { version = "3.2", features = ["derive"] }
9+
clap = { version = "4.1", features = ["derive"] }
1010
env_logger = "0.10"
1111
anyhow = "1"
1212
thiserror = "1"

collector/benchlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ serde = { version = "1.0.143", features = ["derive"] }
1212
serde_json = "1.0.83"
1313
log = "0.4.17"
1414
env_logger = "0.10.0"
15-
clap = { version = "3.2", features = ["derive"] }
15+
clap = { version = "4.1", features = ["derive", "string"] }
1616
libc = "0.2"
1717

1818
[target.'cfg(target_os = "linux")'.dependencies]

collector/benchlib/src/cli.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,26 @@ pub enum Args {
1111
#[derive(clap::Parser, Debug)]
1212
pub struct BenchmarkArgs {
1313
/// How many times should each benchmark be repeated.
14-
#[clap(long, default_value = "5")]
14+
#[arg(long, default_value = "5")]
1515
pub iterations: u32,
1616

1717
/// Exclude all benchmarks matching a prefix in this comma-separated list
18-
#[clap(long)]
18+
#[arg(long)]
1919
pub exclude: Option<String>,
2020

2121
/// Include only benchmarks matching a prefix in this comma-separated list
22-
#[clap(long)]
22+
#[arg(long)]
2323
pub include: Option<String>,
2424
}
2525

26+
#[test]
27+
fn verify_cli() {
28+
// By default, clap lazily checks subcommands. This provides eager testing
29+
// without having to run the binary for each subcommand.
30+
use clap::CommandFactory;
31+
Args::command().debug_assert()
32+
}
33+
2634
pub fn parse_cli() -> anyhow::Result<Args> {
2735
let app = Args::command();
2836

@@ -31,6 +39,7 @@ pub fn parse_cli() -> anyhow::Result<Args> {
3139
std::env::current_exe()?
3240
.file_name()
3341
.and_then(|s| s.to_str())
42+
.map(|s| s.to_owned())
3443
.expect("Binary name not found"),
3544
);
3645

collector/src/benchmark/category.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::{Deserialize, Serialize};
22
use std::fmt;
33

4-
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, clap::ArgEnum)]
4+
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, clap::ValueEnum)]
55
#[serde(rename_all = "kebab-case")]
66
pub enum Category {
77
Primary,

collector/src/benchmark/profile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// to the database crate.
66
// In general, the database versions of types used in the collector should be considered a DB
77
// implementation detail, as they may change when we alter database layout.
8-
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, clap::ArgEnum, serde::Deserialize)]
9-
#[clap(rename_all = "PascalCase")]
8+
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, clap::ValueEnum, serde::Deserialize)]
9+
#[value(rename_all = "PascalCase")]
1010
pub enum Profile {
1111
Check,
1212
Debug,

collector/src/benchmark/scenario.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, clap::ArgEnum, serde::Deserialize)]
2-
#[clap(rename_all = "PascalCase")]
1+
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, clap::ValueEnum, serde::Deserialize)]
2+
#[value(rename_all = "PascalCase")]
33
pub enum Scenario {
44
Full,
55
IncrFull,

0 commit comments

Comments
 (0)