Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

[Merged by Bors] - Bump clap to 4.0 #150

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Added Listener operator to supported operators ([#143](https://github.com/stackabletech/stackablectl/pull/143))
- Support listing distributed MinIO instances ([#148](https://github.com/stackabletech/stackablectl/pull/148))

### Changed

- Bump to clap 4.0 ([#150](https://github.com/stackabletech/stackablectl/pull/150))

## [0.5.0] - 2022-09-14

### Added
Expand Down
24 changes: 8 additions & 16 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ repository = "https://github.com/stackabletech/stackablectl"

[dependencies]
cached = "0.39"
clap = { version = "3.2", features = ["derive", "cargo"] }
clap_complete = "3.2"
clap = { version = "4.0", features = ["derive", "cargo"] }
clap_complete = "4.0"
cli-table = "0.4"
env_logger = "0.9"
indexmap = { version = "1.9", features = ["serde"] }
Expand Down
16 changes: 8 additions & 8 deletions src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
demo::CliCommandDemo, operator::CliCommandOperator, release::CliCommandRelease,
services::CliCommandServices, stack::CliCommandStack,
};
use clap::{ArgEnum, Command, Parser, ValueHint};
use clap::{Command, Parser, ValueEnum, ValueHint};
use clap_complete::{generate, Generator, Shell};
use log::LevelFilter;
use std::io;
Expand All @@ -14,7 +14,7 @@ pub struct CliArgs {
pub cmd: CliCommand,

/// Log level.
#[clap(short, long, arg_enum, default_value = "info")]
#[clap(short, long, value_enum, default_value = "info")]
pub log_level: LogLevel,

/// Namespace where to deploy the products and operators
Expand Down Expand Up @@ -60,7 +60,7 @@ pub struct CliArgs {
/// Have a look at <https://raw.githubusercontent.com/stackabletech/release/main/releases.yaml> for the structure.
/// Can either be a URL or a path to a file, e.g. `https://my.server/my-releases.yaml`, '/etc/my-releases.yaml' or `C:\Users\Bob\my-releases.yaml`.
/// Can be specified multiple times.
#[clap(long, multiple_occurrences(true), value_hint = ValueHint::FilePath)]
#[clap(long, value_hint = ValueHint::FilePath)]
pub additional_releases_file: Vec<String>,

/// Adds a YAML file containing custom stacks
Expand All @@ -69,7 +69,7 @@ pub struct CliArgs {
/// Have a look at <https://raw.githubusercontent.com/stackabletech/stackablectl/main/stacks/stacks-v1.yaml> for the structure.
/// Can either be a URL or a path to a file, e.g. `https://my.server/my-stacks.yaml`, '/etc/my-stacks.yaml' or `C:\Users\Bob\my-stacks.yaml`.
/// Can be specified multiple times.
#[clap(long, multiple_occurrences(true), value_hint = ValueHint::FilePath)]
#[clap(long, value_hint = ValueHint::FilePath)]
pub additional_stacks_file: Vec<String>,

/// Adds a YAML file containing custom demos
Expand All @@ -78,7 +78,7 @@ pub struct CliArgs {
/// Have a look at <https://raw.githubusercontent.com/stackabletech/stackablectl/main/demos/demos-v1.yaml> for the structure.
/// Can either be a URL or a path to a file, e.g. `https://my.server/my-demos.yaml`, '/etc/my-demos.yaml' or `C:\Users\Bob\my-demos.yaml`.
/// Can be specified multiple times.
#[clap(long, multiple_occurrences(true), value_hint = ValueHint::FilePath)]
#[clap(long, value_hint = ValueHint::FilePath)]
pub additional_demos_file: Vec<String>,
}

Expand Down Expand Up @@ -108,14 +108,14 @@ pub enum CliCommand {
Completion(CliCommandCompletion),
}

#[derive(Clone, Parser, ArgEnum)]
#[derive(Clone, Parser, ValueEnum)]
pub enum OutputType {
Text,
Json,
Yaml,
}

#[derive(Clone, Copy, Parser, Debug, ArgEnum)]
#[derive(Clone, Copy, Parser, Debug, ValueEnum)]
pub enum LogLevel {
Error,
Warn,
Expand All @@ -139,7 +139,7 @@ impl From<LogLevel> for LevelFilter {
#[derive(Parser)]
pub struct CliCommandCompletion {
// Shell to generate the completions for
#[clap(arg_enum, value_parser)]
#[clap(value_enum, value_parser)]
pub shell: Shell,
}

Expand Down
6 changes: 3 additions & 3 deletions src/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum CliCommandDemo {
/// List all the available demos
#[clap(alias("ls"))]
List {
#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
/// Show details of a specific demo
Expand All @@ -34,7 +34,7 @@ pub enum CliCommandDemo {
#[clap(required = true, value_hint = ValueHint::Other)]
demo: String,

#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
/// Install a specific demo
Expand All @@ -55,7 +55,7 @@ pub enum CliCommandDemo {
#[clap(
long,
default_value = "stackable-data-platform",
requires = "kind-cluster",
requires = "kind_cluster",
value_hint = ValueHint::Other,
)]
kind_cluster_name: String,
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::arguments::CliCommand;
use arguments::CliArgs;
use clap::{IntoApp, Parser};
use clap::{CommandFactory, Parser};
use lazy_static::lazy_static;
use log::error;
use std::{error::Error, process::exit, sync::Mutex};
Expand Down
14 changes: 7 additions & 7 deletions src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum CliCommandOperator {
/// List all the available operators
#[clap(alias("ls"))]
List {
#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
/// Show details of a specific operator
Expand All @@ -21,7 +21,7 @@ pub enum CliCommandOperator {
#[clap(required = true, value_hint = ValueHint::Other)]
operator: String,

#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
/// Install one or multiple operators
Expand All @@ -31,7 +31,7 @@ pub enum CliCommandOperator {
/// Must have the form `name[=version]` e.g. `superset`, `superset=0.3.0`, `superset=0.3.0-nightly` or `superset=0.3.0-pr123`.
/// If no version is specified the latest nightly version - build from the main branch - will be used.
/// You can get the available versions with `stackablectl operator list` or `stackablectl operator describe superset`
#[clap(multiple_occurrences(true), required = true, value_hint = ValueHint::Other)]
#[clap(required = true, value_hint = ValueHint::Other)]
operators: Vec<Operator>,

/// If specified, a local Kubernetes cluster consisting of 4 nodes (1 for control-plane and 3 workers) for testing purposes will be created.
Expand All @@ -45,7 +45,7 @@ pub enum CliCommandOperator {
#[clap(
long,
default_value = "stackable-data-platform",
requires = "kind-cluster",
requires = "kind_cluster",
value_hint = ValueHint::Other,
)]
kind_cluster_name: String,
Expand All @@ -54,12 +54,12 @@ pub enum CliCommandOperator {
#[clap(alias("un"))]
Uninstall {
/// Space separated list of operators to uninstall.
#[clap(multiple_occurrences(true), required = true, value_hint = ValueHint::Other)]
#[clap(required = true, value_hint = ValueHint::Other)]
operators: Vec<String>,
},
/// List installed operators
Installed {
#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
}
Expand Down Expand Up @@ -271,7 +271,7 @@ fn list_installed_operators(output_type: &OutputType) -> Result<(), Box<dyn Erro
Ok(())
}

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct Operator {
pub name: String,
pub version: Option<String>,
Expand Down
10 changes: 5 additions & 5 deletions src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum CliCommandRelease {
/// List all the available releases
#[clap(alias("ls"))]
List {
#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
/// Show details of a specific release
Expand All @@ -28,15 +28,15 @@ pub enum CliCommandRelease {
#[clap(required = true, value_hint = ValueHint::Other)]
release: String,

#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
/// Install a specific release
#[clap(alias("in"))]
#[clap(group(
ArgGroup::new("list-of-products")
ArgGroup::new("list_of_products")
.required(false)
.args(&["include-products", "exclude-products"]),
.args(&["include_products", "exclude_products"]),
))]
Install {
/// Name of the release to install
Expand Down Expand Up @@ -64,7 +64,7 @@ pub enum CliCommandRelease {
#[clap(
long,
default_value = "stackable-data-platform",
requires = "kind-cluster",
requires = "kind_cluster",
value_hint = ValueHint::Other,
)]
kind_cluster_name: String,
Expand Down
2 changes: 1 addition & 1 deletion src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub enum CliCommandServices {
#[clap(long)]
show_versions: bool,

#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
}
Expand Down
6 changes: 3 additions & 3 deletions src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum CliCommandStack {
/// List all the available stacks
#[clap(alias("ls"))]
List {
#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
/// Show details of a specific stack
Expand All @@ -29,7 +29,7 @@ pub enum CliCommandStack {
#[clap(required = true, value_hint = ValueHint::Other)]
stack: String,

#[clap(short, long, arg_enum, default_value = "text")]
#[clap(short, long, value_enum, default_value = "text")]
output: OutputType,
},
/// Install a specific stack
Expand All @@ -50,7 +50,7 @@ pub enum CliCommandStack {
#[clap(
long,
default_value = "stackable-data-platform",
requires = "kind-cluster",
requires = "kind_cluster",
value_hint = ValueHint::Other,
)]
kind_cluster_name: String,
Expand Down