Skip to content

Commit a71a7b2

Browse files
committed
chore: update clap dependency from v3 to v4
Signed-off-by: Matheus Cardoso <matheus@cardo.so>
1 parent ac72786 commit a71a7b2

File tree

13 files changed

+79
-40
lines changed

13 files changed

+79
-40
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async-trait = "0.1"
1717
bindle = { workspace = true }
1818
bytes = "1.1"
1919
chrono = "0.4"
20-
clap = { version = "3.1.15", features = ["derive", "env"] }
20+
clap = { version = "4.1", features = ["derive", "env"] }
2121
cloud = { path = "crates/cloud" }
2222
cloud-openapi = { git = "https://github.com/fermyon/cloud-openapi" }
2323
comfy-table = "5.0"

crates/http/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ doctest = false
1010
[dependencies]
1111
anyhow = "1.0"
1212
async-trait = "0.1"
13-
clap = "3"
13+
clap = "4"
1414
futures = "0.3"
1515
futures-util = "0.3.8"
1616
http = "0.2"

crates/http/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ pub struct CliArgs {
6363
pub address: SocketAddr,
6464

6565
/// The path to the certificate to use for https, if this is not set, normal http will be used. The cert should be in PEM format
66-
#[clap(long, env = "SPIN_TLS_CERT", requires = "tls-key")]
66+
#[clap(long = "tls-cert", env = "SPIN_TLS_CERT", requires = "tls_key")]
6767
pub tls_cert: Option<PathBuf>,
6868

6969
/// The path to the certificate key to use for https, if this is not set, normal http will be used. The key should be in PKCS#8 format
70-
#[clap(long, env = "SPIN_TLS_KEY", requires = "tls-cert")]
70+
#[clap(long = "tls-key", env = "SPIN_TLS_KEY", requires = "tls_cert")]
7171
pub tls_key: Option<PathBuf>,
7272
}
7373

crates/trigger/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = { workspace = true }
77
[dependencies]
88
anyhow = "1.0"
99
async-trait = "0.1"
10-
clap = { version = "3.1.15", features = ["derive", "env"] }
10+
clap = { version = "4.1", features = ["derive", "env"] }
1111
ctrlc = { version = "3.2", features = ["termination"] }
1212
dirs = "4"
1313
futures = "0.3"

crates/trigger/src/cli.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::PathBuf;
22

33
use anyhow::{Context, Result};
4-
use clap::{Args, IntoApp, Parser};
4+
use clap::{Args, CommandFactory, Parser};
55
use serde::de::DeserializeOwned;
66
use tokio::{
77
task::JoinHandle,
@@ -43,7 +43,7 @@ where
4343
long = "disable-cache",
4444
env = DISABLE_WASMTIME_CACHE,
4545
conflicts_with = WASMTIME_CACHE_FILE,
46-
takes_value = false,
46+
num_args = 0,
4747
)]
4848
pub disable_cache: bool,
4949

@@ -59,9 +59,8 @@ where
5959
/// Print output for given component(s) to stdout/stderr
6060
#[clap(
6161
name = FOLLOW_LOG_OPT,
62-
long = "follow",
63-
multiple_occurrences = true,
64-
)]
62+
long = "follow"
63+
)]
6564
pub follow_components: Vec<String>,
6665

6766
/// Print all component output to stdout/stderr

src/commands/bindle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct Prepare {
4141
#[clap(
4242
name = BUILDINFO_OPT,
4343
long = "buildinfo",
44-
parse(try_from_str = parse_buildinfo),
44+
value_parser = parse_buildinfo,
4545
)]
4646
pub buildinfo: Option<BuildMetadata>,
4747

@@ -69,7 +69,7 @@ pub struct Push {
6969
#[clap(
7070
name = BUILDINFO_OPT,
7171
long = "buildinfo",
72-
parse(try_from_str = parse_buildinfo),
72+
value_parser = parse_buildinfo,
7373
)]
7474
pub buildinfo: Option<BuildMetadata>,
7575

@@ -113,7 +113,7 @@ pub struct Push {
113113
name = INSECURE_OPT,
114114
short = 'k',
115115
long = "insecure",
116-
takes_value = false,
116+
num_args = 0,
117117
)]
118118
pub insecure: bool,
119119
}

src/commands/deploy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub struct DeployCommand {
7272
#[clap(
7373
name = BUILDINFO_OPT,
7474
long = "buildinfo",
75-
parse(try_from_str = parse_buildinfo),
75+
value_parser = parse_buildinfo,
7676
)]
7777
pub buildinfo: Option<BuildMetadata>,
7878

src/commands/external.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::opts::PLUGIN_OVERRIDE_COMPATIBILITY_CHECK_FLAG;
22
use anyhow::{anyhow, Result};
3-
use clap::App;
3+
use clap;
44
use spin_plugins::{error::Error, manifest::check_supported_version, PluginStore};
55
use std::{collections::HashMap, env, process};
66
use tokio::process::Command;
@@ -33,7 +33,10 @@ fn parse_subcommand(mut cmd: Vec<String>) -> anyhow::Result<(String, Vec<String>
3333
/// Executes a Spin plugin as a subprocess, expecting the first argument to
3434
/// indicate the plugin to execute. Passes all subsequent arguments on to the
3535
/// subprocess.
36-
pub async fn execute_external_subcommand(cmd: Vec<String>, app: App<'_>) -> anyhow::Result<()> {
36+
pub async fn execute_external_subcommand(
37+
cmd: Vec<String>,
38+
app: clap::Command,
39+
) -> anyhow::Result<()> {
3740
let (plugin_name, args, override_compatibility_check) = parse_subcommand(cmd)?;
3841
let plugin_store = PluginStore::try_default()?;
3942
match plugin_store.read_plugin_manifest(&plugin_name) {

src/commands/login.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct LoginCommand {
6363
name = INSECURE_OPT,
6464
short = 'k',
6565
long = "insecure",
66-
takes_value = false,
66+
num_args = 0,
6767
)]
6868
pub insecure: bool,
6969

@@ -99,7 +99,7 @@ pub struct LoginCommand {
9999
#[clap(
100100
name = "status",
101101
long = "status",
102-
takes_value = false,
102+
num_args = 0,
103103
conflicts_with = "list",
104104
conflicts_with = "get-device-code",
105105
conflicts_with = "check-device-code"
@@ -110,7 +110,7 @@ pub struct LoginCommand {
110110
#[clap(
111111
name = "get-device-code",
112112
long = "get-device-code",
113-
takes_value = false,
113+
num_args = 0,
114114
hide = true,
115115
conflicts_with = "status",
116116
conflicts_with = "check-device-code"
@@ -132,7 +132,7 @@ pub struct LoginCommand {
132132
name = "auth-method",
133133
long = "auth-method",
134134
env = "AUTH_METHOD",
135-
arg_enum
135+
value_enum
136136
)]
137137
pub method: Option<AuthMethod>,
138138

@@ -149,7 +149,7 @@ pub struct LoginCommand {
149149
#[clap(
150150
name = "list",
151151
long = "list",
152-
takes_value = false,
152+
num_args = 0,
153153
conflicts_with = "environment-name",
154154
conflicts_with = "status",
155155
conflicts_with = "get-device-code",
@@ -540,7 +540,7 @@ fn ensure(root: &PathBuf) -> Result<()> {
540540
}
541541

542542
/// The method by which to authenticate the login.
543-
#[derive(clap::ArgEnum, Clone, Debug, Eq, PartialEq)]
543+
#[derive(clap::ValueEnum, Clone, Debug, Eq, PartialEq)]
544544
pub enum AuthMethod {
545545
#[clap(name = "github")]
546546
Github,

0 commit comments

Comments
 (0)