Skip to content

Commit 55ed2f8

Browse files
committed
Bump clap to 4.0 (#503)
1 parent 86c3633 commit 55ed2f8

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ All notable changes to this project will be documented in this file.
88

99
- BREAKING: `get_recommended_labels` and `with_recommended_labels` now takes a struct of named arguments ([#501]).
1010
- Bump opentelemetry crates ([#502]).
11+
- Bump clap to 4.0 ([#503]).
1112

1213
[#501]: https://github.com/stackabletech/operator-rs/pull/501
1314
[#502]: https://github.com/stackabletech/operator-rs/pull/502
15+
[#503]: https://github.com/stackabletech/operator-rs/pull/503
1416

1517
## [0.26.1] - 2022-11-08
1618

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository = "https://github.com/stackabletech/operator-rs"
99

1010
[dependencies]
1111
chrono = { version = "0.4.22", default-features = false }
12-
clap = { version = "3.2.23", features = ["derive", "cargo", "env"] }
12+
clap = { version = "4.0.22", features = ["derive", "cargo", "env"] }
1313
const_format = "0.2.30"
1414
either = "1.8.0"
1515
futures = "0.3.25"

src/cli.rs

+18-13
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
//! }
4141
//!
4242
//! #[derive(clap::Parser)]
43-
//! #[clap(
43+
//! #[command(
4444
//! name = "Foobar Operator",
4545
//! author,
4646
//! version,
@@ -52,7 +52,7 @@
5252
//! }
5353
//!
5454
//! # fn main() -> OperatorResult<()> {
55-
//! let opts = Opts::from_args();
55+
//! let opts = Opts::parse();
5656
//!
5757
//! match opts.command {
5858
//! cli::Command::Crd => {
@@ -75,7 +75,7 @@
7575
//! use stackable_operator::error::OperatorResult;
7676
//!
7777
//! #[derive(clap::Parser)]
78-
//! #[clap(
78+
//! #[command(
7979
//! name = "Foobar Operator",
8080
//! author,
8181
//! version,
@@ -87,7 +87,7 @@
8787
//! }
8888
//!
8989
//! # fn main() -> OperatorResult<()> {
90-
//! let opts = Opts::from_args();
90+
//! let opts = Opts::parse();
9191
//!
9292
//! match opts.command {
9393
//! cli::Command::Crd => {
@@ -133,7 +133,7 @@ pub const AUTHOR: &str = "Stackable GmbH - info@stackable.de";
133133
#[derive(clap::Parser, Debug, PartialEq, Eq)]
134134
// The enum-level doccomment is intended for developers, not end users
135135
// so supress it from being included in --help
136-
#[clap(long_about = "")]
136+
#[command(long_about = "")]
137137
pub enum Command<Run: Args = ProductOperatorRun> {
138138
/// Print CRD objects
139139
Crd,
@@ -174,7 +174,7 @@ pub enum Command<Run: Args = ProductOperatorRun> {
174174
/// # use stackable_operator::cli::{Command, ProductOperatorRun};
175175
/// #[derive(clap::Parser, Debug, PartialEq, Eq)]
176176
/// struct Run {
177-
/// #[clap(long)]
177+
/// #[arg(long)]
178178
/// name: String,
179179
/// }
180180
/// use clap::Parser;
@@ -184,28 +184,27 @@ pub enum Command<Run: Args = ProductOperatorRun> {
184184
/// }));
185185
/// ```
186186
#[derive(clap::Parser, Debug, PartialEq, Eq)]
187-
#[clap(long_about = "")]
187+
#[command(long_about = "")]
188188
pub struct ProductOperatorRun {
189189
/// Provides the path to a product-config file
190-
#[clap(
190+
#[arg(
191191
long,
192192
short = 'p',
193193
value_name = "FILE",
194194
default_value = "",
195-
env,
196-
parse(from_os_str)
195+
env
197196
)]
198197
pub product_config: ProductConfigPath,
199198
/// Provides a specific namespace to watch (instead of watching all namespaces)
200-
#[clap(long, env, default_value = "", parse(from_str))]
199+
#[arg(long, env, default_value = "")]
201200
pub watch_namespace: WatchNamespace,
202201
/// Tracing log collector system
203-
#[clap(long, env, default_value_t, arg_enum)]
202+
#[arg(long, env, default_value_t, value_enum)]
204203
pub tracing_target: TracingTarget,
205204
}
206205

207206
/// A path to a [`ProductConfigManager`] spec file
208-
#[derive(Debug, PartialEq, Eq)]
207+
#[derive(Clone, Debug, PartialEq, Eq)]
209208
pub struct ProductConfigPath {
210209
path: Option<PathBuf>,
211210
}
@@ -274,6 +273,12 @@ mod tests {
274273
const DEFAULT_FILE_PATH: &str = "default_file_path_properties.yaml";
275274
const WATCH_NAMESPACE: &str = "WATCH_NAMESPACE";
276275

276+
#[test]
277+
fn verify_cli() {
278+
use clap::CommandFactory;
279+
ProductOperatorRun::command().debug_assert()
280+
}
281+
277282
#[rstest]
278283
#[case(
279284
Some(USER_PROVIDED_PATH),

src/logging/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilte
44
pub mod controller;
55
mod k8s_events;
66

7-
#[derive(Debug, Clone, clap::ArgEnum, PartialEq, Eq)]
7+
#[derive(Debug, Clone, clap::ValueEnum, PartialEq, Eq)]
88
pub enum TracingTarget {
99
None,
1010
Jaeger,

0 commit comments

Comments
 (0)