From 1a25d958df9ed194f58576f0f8da2b9ea9085e42 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:00:55 +0000 Subject: [PATCH 1/4] Update Rust crate clap to v4 --- cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 7d89beb..8980d64 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -13,7 +13,7 @@ lto = true opt-level = 0 [dependencies] -clap = { version = "3.2.25", features = ["derive"] } +clap = { version = "4.4.8", features = ["derive"] } clap_complete = "3.2.5" dirs = "4.0.0" anyhow = "1.0.75" From 32cebc9f81626b83a78c7aef9e56817e5f1f87e4 Mon Sep 17 00:00:00 2001 From: mdpadberg Date: Thu, 16 Nov 2023 14:58:14 +0100 Subject: [PATCH 2/4] Implement new clap api #39 --- cli/Cargo.toml | 3 ++- cli/src/cli.rs | 12 ++++++------ cli/src/environment.rs | 7 ++++--- cli/src/subcommands.rs | 21 +++++++++++---------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 8980d64..47ecf82 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -2,6 +2,7 @@ name = "mcf" version = "0.17.0" edition = "2021" +default-run = "mcf" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -14,7 +15,7 @@ opt-level = 0 [dependencies] clap = { version = "4.4.8", features = ["derive"] } -clap_complete = "3.2.5" +clap_complete = "4.4.4" dirs = "4.0.0" anyhow = "1.0.75" log = "0.4.0" diff --git a/cli/src/cli.rs b/cli/src/cli.rs index cf0b442..29fbce3 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -8,19 +8,19 @@ use lib::{ use std::{io, path::PathBuf, sync::Arc}; #[derive(Parser, Debug)] -#[clap(author, version, about, long_about = None)] -#[clap(name = "mcf")] -#[clap(bin_name = "mcf")] +#[command(author, version, about, long_about = None)] +#[command(name = "mcf")] +#[command(bin_name = "mcf")] struct Mcf { - #[clap(subcommand)] + #[command(subcommand)] command: Subcommands, /// Overwrite mcf config path - #[clap(long, global = true)] + #[arg(long, global = true)] override_path: Option, /// Overwrite binary name for cloudfoundry cli (for example: "cf8") - #[clap(long, global = true)] + #[arg(long, global = true)] cf_binary_name: Option, } diff --git a/cli/src/environment.rs b/cli/src/environment.rs index be3c130..2eff316 100644 --- a/cli/src/environment.rs +++ b/cli/src/environment.rs @@ -12,15 +12,16 @@ pub enum EnvironmentCommands { Add { name: String, url: String, - #[clap(long)] + #[arg(long)] sso: bool, - #[clap(long)] + #[arg(long)] skip_ssl_validation: bool, }, - #[clap(visible_alias = "rm")] /// Remove an environment to the environment list + #[command(visible_alias = "rm")] Remove { name: String }, /// List all the environment you stored + #[command(visible_alias = "ls")] List, } diff --git a/cli/src/subcommands.rs b/cli/src/subcommands.rs index a635f55..439e316 100644 --- a/cli/src/subcommands.rs +++ b/cli/src/subcommands.rs @@ -1,43 +1,44 @@ use crate::environment::EnvironmentCommands; +use clap::Subcommand; use clap_complete::Shell; -#[derive(clap::Subcommand, Debug)] +#[derive(Subcommand, Debug)] pub enum Subcommands { /// Add, Remove, List environment (example cf-dev) - #[clap(visible_alias = "env")] + #[command(visible_alias = "env")] Environment { - #[clap(subcommand)] + #[command(subcommand)] environment_commands: EnvironmentCommands, }, /// Login to one of the Cloud Foundry environments - #[clap(visible_alias = "l")] + #[command(visible_alias = "l")] Login { /// Name of the environment (example "cf-dev") name: String, /// One-time passcode - #[clap(long)] + #[arg(long)] sso_passcode: Option, /// Cloudfoundry organization - #[clap(short,long)] + #[arg(short,long)] org: Option, /// Cloudfoundry space - #[clap(short,long)] + #[arg(short,long)] space: Option, }, /// Execute command on Cloud Foundry environment - #[clap(visible_alias = "e", trailing_var_arg = true)] + #[command(visible_alias = "e", trailing_var_arg = true)] Exec { /// Names of the environments (example "cf-dev,cf-prod") names: String, /// Command you want to execute (example "logs your-application --recent") command: Vec, /// Execute command sequentially (example "ssh your-application") - #[clap(short, long)] + #[arg(short, long)] sequential_mode: bool }, /// Generate shell autocompletion files Completion { - #[clap(arg_enum, value_parser)] + #[arg(value_enum)] shell: Shell, }, } From 561e49268bd77ecaa5d2a0526609317adb2c3257 Mon Sep 17 00:00:00 2001 From: mdpadberg Date: Fri, 17 Nov 2023 09:56:28 +0100 Subject: [PATCH 3/4] adjust test based on new clap api #39 --- integration/tests/integration_test.rs | 33 +++++++++++---------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/integration/tests/integration_test.rs b/integration/tests/integration_test.rs index 9b60333..79352e2 100644 --- a/integration/tests/integration_test.rs +++ b/integration/tests/integration_test.rs @@ -8,28 +8,21 @@ fn can_run_mcf() { cmd.assert().success(); let expected_output = format!( r###" -USAGE: - mcf [OPTIONS] +Usage: mcf environment [OPTIONS] -OPTIONS: - --cf-binary-name - Overwrite binary name for cloudfoundry cli (for example: "cf8") +Commands: + add Add an environment to the environment list + remove Remove an environment to the environment list [aliases: rm] + list List all the environment you stored [aliases: ls] + help Print this message or the help of the given subcommand(s) - -h, --help - Print help information - - --override-path - Overwrite mcf config path - - -V, --version - Print version information - -SUBCOMMANDS: - completion Generate shell autocompletion files - environment Add, Remove, List environment (example cf-dev) [aliases: env] - exec Execute command on Cloud Foundry environment [aliases: e] - help Print this message or the help of the given subcommand(s) - login Login to one of the Cloud Foundry environments [aliases: l] +Options: + --override-path + Overwrite mcf config path + --cf-binary-name + Overwrite binary name for cloudfoundry cli (for example: "cf8") +-h, --help + Print help "### ); let actual_output = String::from_utf8(cmd.assert().get_output().to_owned().stdout).unwrap(); From 2be67f0b15680430d6c06013f7b62b39d1f553e0 Mon Sep 17 00:00:00 2001 From: mdpadberg Date: Fri, 17 Nov 2023 10:10:02 +0100 Subject: [PATCH 4/4] adjust test based on new clap api #39 --- integration/tests/integration_test.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/integration/tests/integration_test.rs b/integration/tests/integration_test.rs index 79352e2..3cf39db 100644 --- a/integration/tests/integration_test.rs +++ b/integration/tests/integration_test.rs @@ -7,22 +7,24 @@ fn can_run_mcf() { cmd.arg("-h"); cmd.assert().success(); let expected_output = format!( - r###" -Usage: mcf environment [OPTIONS] + r###"Usage: mcf [OPTIONS] Commands: - add Add an environment to the environment list - remove Remove an environment to the environment list [aliases: rm] - list List all the environment you stored [aliases: ls] - help Print this message or the help of the given subcommand(s) + environment Add, Remove, List environment (example cf-dev) [aliases: env] + login Login to one of the Cloud Foundry environments [aliases: l] + exec Execute command on Cloud Foundry environment [aliases: e] + completion Generate shell autocompletion files + help Print this message or the help of the given subcommand(s) Options: - --override-path - Overwrite mcf config path - --cf-binary-name - Overwrite binary name for cloudfoundry cli (for example: "cf8") --h, --help - Print help + --override-path + Overwrite mcf config path + --cf-binary-name + Overwrite binary name for cloudfoundry cli (for example: "cf8") + -h, --help + Print help + -V, --version + Print version "### ); let actual_output = String::from_utf8(cmd.assert().get_output().to_owned().stdout).unwrap();