diff --git a/Cargo.lock b/Cargo.lock index 13d5cea..b1cace8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,6 +160,7 @@ version = "0.1.1" dependencies = [ "axum", "clap", + "clap-cargo", "include_dir", "serde", "serde_json", @@ -183,6 +184,16 @@ dependencies = [ "clap_derive", ] +[[package]] +name = "clap-cargo" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d546f0e84ff2bfa4da1ce9b54be42285767ba39c688572ca32412a09a73851e5" +dependencies = [ + "anstyle", + "clap", +] + [[package]] name = "clap_builder" version = "4.5.38" diff --git a/Cargo.toml b/Cargo.toml index 5495e70..565bba1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ include = ["/public", "/src"] [dependencies] axum = { version = "0.8.4", features = ["macros"] } clap = { version = "4.5.38", features = ["derive"] } +clap-cargo = "0.15.2" include_dir = "0.7.4" serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" diff --git a/src/main.rs b/src/main.rs index 59f3329..766446c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,15 +5,32 @@ use tokio::runtime::Builder; mod server; +pub const CLAP_STYLING: clap::builder::styling::Styles = clap::builder::styling::Styles::styled() + .header(clap_cargo::style::HEADER) + .usage(clap_cargo::style::USAGE) + .literal(clap_cargo::style::LITERAL) + .placeholder(clap_cargo::style::PLACEHOLDER) + .error(clap_cargo::style::ERROR) + .valid(clap_cargo::style::VALID) + .invalid(clap_cargo::style::INVALID); + #[derive(Parser, Debug)] -#[command(version)] +#[command(name = "cargo")] +#[command(bin_name = "cargo")] +#[command(styles = CLAP_STYLING)] +enum Cli { + Spiel(CliArgs), +} + +#[derive(clap::Args, Debug)] +#[command(version, about, long_about = None)] struct CliArgs { /// Directory of the Cargo project pub project: Option, } fn main() { - let args = CliArgs::parse(); + let Cli::Spiel(args) = Cli::parse(); let runtime = Builder::new_current_thread() .worker_threads(2) .enable_io()