Skip to content
Draft
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
140 changes: 29 additions & 111 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ rust-version = "1.86"
anyhow = { workspace = true }
async-trait = { workspace = true }
bytes = { workspace = true }
# 'deprecated' enables deprecation warnings
clap = { workspace = true, features = ["deprecated", "derive", "env"] }
clap = { workspace = true, features = ["derive", "env", "string", "wrap_help"] }
clap_lex = "0.7.5"
clearscreen = "4"
comfy-table = "7"
command-group = "2"
Expand Down Expand Up @@ -125,7 +125,7 @@ async-trait = "0.1"
base64 = "0.22"
bytes = "1"
chrono = "0.4"
clap = "3.2"
clap = "4.5.45"
conformance-tests = { git = "https://github.com/fermyon/conformance-tests", rev = "61f2799f92b5d85f342cc07e3f5dec5cd0a7bc9c" }
ctrlc = { version = "3.4", features = ["termination"] }
dialoguer = "0.11"
Expand Down
1 change: 1 addition & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = { workspace = true }

[dependencies]
anyhow = { workspace = true }
clap = { workspace = true }
dirs = { workspace = true }
sha2 = { workspace = true }
tempfile = { workspace = true }
Expand Down
10 changes: 10 additions & 0 deletions crates/common/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Common CLI code and constants

use clap::builder::{styling::AnsiColor, Styles};

/// Clap [`Styles`] for Spin CLI and plugins.
pub const CLAP_STYLES: Styles = Styles::styled()
.header(AnsiColor::Yellow.on_default())
.usage(AnsiColor::Green.on_default())
.literal(AnsiColor::Green.on_default())
.placeholder(AnsiColor::Green.on_default());
1 change: 1 addition & 0 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// - Code should have at least 2 dependents

pub mod arg_parser;
pub mod cli;
pub mod data_dir;
pub mod paths;
pub mod sha256;
Expand Down
5 changes: 1 addition & 4 deletions crates/expressions/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ mod tests {
let template = Template::new(tmpl).unwrap();
assert!(
template.parts().eq(&expected),
"{:?} -> {:?} != {:?}",
tmpl,
template,
expected,
"{tmpl:?} -> {template:?} != {expected:?}",
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/trigger-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ pub struct CliArgs {
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")]
#[clap(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")]
#[clap(long, env = "SPIN_TLS_KEY", requires = "tls_cert")]
pub tls_key: Option<PathBuf>,

#[clap(long = "find-free-port")]
Expand Down
2 changes: 1 addition & 1 deletion crates/trigger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ unsafe-aot-compilation = []

[dependencies]
anyhow = { workspace = true }
clap = { workspace = true, features = ["derive", "env"] }
clap = { workspace = true, features = ["derive", "env", "wrap_help"] }
ctrlc = { workspace = true }
futures = { workspace = true }
sanitize-filename = "0.5"
Expand Down
8 changes: 4 additions & 4 deletions crates/trigger/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::PathBuf;
use std::{future::Future, sync::Arc};

use anyhow::{Context, Result};
use clap::{Args, IntoApp, Parser};
use clap::{Args, CommandFactory, Parser};
use spin_app::App;
use spin_common::sloth;
use spin_common::ui::quoted_path;
Expand Down Expand Up @@ -41,6 +41,7 @@ pub const SPIN_WORKING_DIR: &str = "SPIN_WORKING_DIR";
/// A command that runs a TriggerExecutor.
#[derive(Parser, Debug)]
#[clap(
styles = spin_common::cli::CLAP_STYLES,
override_usage = "spin [COMMAND] [OPTIONS]",
next_help_heading = help_heading::<T, B::Factors>()
)]
Expand Down Expand Up @@ -68,7 +69,6 @@ pub struct FactorsTriggerCommand<T: Trigger<B::Factors>, B: RuntimeFactorsBuilde
long = "disable-cache",
env = DISABLE_WASMTIME_CACHE,
conflicts_with = WASMTIME_CACHE_FILE,
takes_value = false,
)]
pub disable_cache: bool,

Expand Down Expand Up @@ -287,9 +287,9 @@ fn warn_if_wasm_build_slothful() -> sloth::SlothGuard {

fn help_heading<T: Trigger<F>, F: RuntimeFactors>() -> Option<&'static str> {
if T::TYPE == <help::HelpArgsOnlyTrigger as Trigger<F>>::TYPE {
Some("TRIGGER OPTIONS")
Some("Trigger Options")
} else {
let heading = format!("{} TRIGGER OPTIONS", T::TYPE.to_uppercase());
let heading = format!("{} Trigger Options", T::TYPE.to_uppercase());
let as_str = Box::new(heading).leak();
Some(as_str)
}
Expand Down
Loading
Loading