Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update clap dependency to 4.1 #1198

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
49 changes: 43 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async-trait = "0.1"
bindle = { workspace = true }
bytes = "1.1"
chrono = "0.4"
clap = { version = "3.1.15", features = ["derive", "env"] }
clap = { version = "4.1.6", features = ["derive", "env"] }
cloud = { path = "crates/cloud" }
cloud-openapi = { git = "https://github.com/fermyon/cloud-openapi" }
comfy-table = "5.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/abi-conformance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = { workspace = true }
[dependencies]
anyhow = "1.0.44"
cap-std = "1.0.3"
clap = { version = "3.1.15", features = ["derive", "env"] }
clap = { version = "4.1.6", features = ["derive", "env"] }
rand = "0.8.5"
rand_chacha = "0.3.1"
rand_core = "0.6.3"
Expand Down
8 changes: 4 additions & 4 deletions crates/abi-conformance/src/bin/spin-abi-conformance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ use std::{
use wasmtime::{Config, Engine, Module};

#[derive(Parser)]
#[clap(author, version, about)]
#[command(author, version, about)]
pub struct Options {
/// Name of Wasm file to test (or stdin if not specified)
#[clap(short, long)]
#[arg(short, long)]
pub input: Option<PathBuf>,

/// Name of JSON file to write report to (or stdout if not specified)
#[clap(short, long)]
#[arg(short, long)]
pub output: Option<PathBuf>,

/// Name of TOML configuration file to use
#[clap(short, long)]
#[arg(short, long)]
pub config: Option<PathBuf>,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ doctest = false
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
clap = "3"
clap = "4.1.6"
futures = "0.3"
futures-util = "0.3.8"
http = "0.2"
Expand Down
6 changes: 3 additions & 3 deletions crates/http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ pub struct HttpTrigger {
#[derive(Args)]
pub struct CliArgs {
/// IP address and port to listen on
#[clap(long = "listen", default_value = "127.0.0.1:3000", value_parser = parse_listen_addr)]
#[arg(long = "listen", default_value = "127.0.0.1:3000", value_parser = parse_listen_addr)]
pub address: SocketAddr,

/// 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
#[clap(long, env = "SPIN_TLS_CERT", requires = "tls-key")]
#[arg(long, env = "SPIN_TLS_CERT", requires = "tls_key")]
pub tls_cert: Option<PathBuf>,

/// 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
#[clap(long, env = "SPIN_TLS_KEY", requires = "tls-cert")]
#[arg(long, env = "SPIN_TLS_KEY", requires = "tls_cert")]
pub tls_key: Option<PathBuf>,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/trigger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = { workspace = true }
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
clap = { version = "3.1.15", features = ["derive", "env"] }
clap = { version = "4.1", features = ["derive", "env"] }
ctrlc = { version = "3.2", features = ["termination"] }
dirs = "4"
futures = "0.3"
Expand Down
28 changes: 14 additions & 14 deletions crates/trigger/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;

use anyhow::{Context, Result};
use clap::{Args, IntoApp, Parser};
use clap::{ArgAction, Args, CommandFactory, Parser};
use serde::de::DeserializeOwned;
use tokio::{
task::JoinHandle,
Expand All @@ -26,31 +26,31 @@ pub const SPIN_WORKING_DIR: &str = "SPIN_WORKING_DIR";

/// A command that runs a TriggerExecutor.
#[derive(Parser, Debug)]
#[clap(next_help_heading = "TRIGGER OPTIONS")]
#[command(next_help_heading = "TRIGGER OPTIONS", ignore_errors = true)]
pub struct TriggerExecutorCommand<Executor: TriggerExecutor>
where
Executor::RunConfig: Args,
{
/// Log directory for the stdout and stderr of components.
#[clap(
#[arg(
name = APP_LOG_DIR,
short = 'L',
long = "log-dir",
)]
pub log: Option<PathBuf>,

/// Disable Wasmtime cache.
#[clap(
#[arg(
name = DISABLE_WASMTIME_CACHE,
long = "disable-cache",
env = DISABLE_WASMTIME_CACHE,
conflicts_with = WASMTIME_CACHE_FILE,
takes_value = false,
action = ArgAction::SetTrue,
)]
pub disable_cache: bool,

/// Wasmtime cache configuration file.
#[clap(
#[arg(
name = WASMTIME_CACHE_FILE,
long = "cache",
env = WASMTIME_CACHE_FILE,
Expand All @@ -59,15 +59,15 @@ where
pub cache: Option<PathBuf>,

/// Print output to stdout/stderr only for given component(s)
#[clap(
#[arg(
name = FOLLOW_LOG_OPT,
long = "follow",
multiple_occurrences = true,
action = ArgAction::Append,
)]
pub follow_components: Vec<String>,

/// Silence all component output to stdout/stderr
#[clap(
#[arg(
long = "quiet",
short = 'q',
aliases = &["sh", "shush"],
Expand All @@ -76,25 +76,25 @@ where
pub silence_component_logs: bool,

/// Set the static assets of the components in the temporary directory as writable.
#[clap(long = "allow-transient-write")]
#[arg(long = "allow-transient-write")]
pub allow_transient_write: bool,

/// Configuration file for config providers and wasmtime config.
#[clap(
#[arg(
name = RUNTIME_CONFIG_FILE,
long = "runtime-config-file",
env = RUNTIME_CONFIG_FILE,
)]
pub runtime_config_file: Option<PathBuf>,

#[clap(flatten)]
#[command(flatten)]
pub run_config: Executor::RunConfig,

#[clap(long = "help-args-only", hide = true)]
#[arg(long = "help-args-only", hide = true)]
pub help_args_only: bool,

/// Load the application from the registry.
#[clap(long = "from-registry", hide = true)]
#[arg(long = "from-registry", hide = true)]
pub from_registry: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion examples/spin-timer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
anyhow = "1.0.68"
async-trait = "0.1"
clap = { version = "3.1.15", features = ["derive", "env"] }
clap = { version = "4.1", features = ["derive", "env"] }
futures = "0.3.25"
serde = "1.0"
spin-core = { version = "0.7.1", path = "../../crates/core" }
Expand Down
1 change: 0 additions & 1 deletion examples/spin-timer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::HashMap;

use anyhow::Error;
use clap::{Parser};
use serde::{Deserialize, Serialize};
use spin_trigger::{cli::TriggerExecutorCommand, TriggerExecutor, TriggerAppEngine};

Expand Down
20 changes: 11 additions & 9 deletions src/bin/spin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,42 @@ fn version() -> &'static str {

/// The Spin CLI
#[derive(Parser)]
#[clap(
#[command(
name = "spin",
version = version(),
next_display_order = None
)]
enum SpinApp {
#[clap(subcommand, alias = "template")]
#[command(subcommand, alias = "template")]
Templates(TemplateCommands),
New(NewCommand),
Add(AddCommand),
Up(UpCommand),
#[clap(subcommand)]
#[command(subcommand)]
Bindle(BindleCommands),
#[clap(subcommand)]
#[command(subcommand)]
Cloud(CloudCommands),
// acts as a cross-level subcommand shortcut -> `spin cloud deploy`
Deploy(DeployCommand),
// acts as a cross-level subcommand shortcut -> `spin cloud login`
Login(LoginCommand),
#[clap(subcommand, alias = "oci")]
#[command(subcommand, alias = "oci")]
Registry(RegistryCommands),
Build(BuildCommand),
#[clap(subcommand, alias = "plugin")]
#[command(subcommand, alias = "plugin")]
Plugins(PluginCommands),
#[clap(subcommand, hide = true)]
#[command(subcommand, hide = true)]
Trigger(TriggerCommands),
#[clap(external_subcommand)]
#[command(external_subcommand)]
External(Vec<String>),
}

#[derive(Subcommand)]
#[command(next_display_order = None, ignore_errors=true)]
enum TriggerCommands {
Http(TriggerExecutorCommand<HttpTrigger>),
Redis(TriggerExecutorCommand<RedisTrigger>),
#[clap(name = spin_cli::HELP_ARGS_ONLY_TRIGGER_TYPE, hide = true)]
#[command(name = spin_cli::HELP_ARGS_ONLY_TRIGGER_TYPE, hide = true)]
HelpArgsOnly(TriggerExecutorCommand<HelpArgsOnlyTrigger>),
}

Expand Down
Loading