From d36ed0d6626e79d9a601f21ce5d1bfa734217a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20J=C3=B6hnk?= Date: Tue, 5 Nov 2024 23:10:59 +0100 Subject: [PATCH] chore: replace structopt with clap --- Cargo.lock | 165 ++++++++++++++++++++------------------ crates/mizer/Cargo.toml | 2 +- crates/mizer/src/flags.rs | 15 ++-- crates/mizer/src/main.rs | 5 +- 4 files changed, 96 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10587c1e0..d526b23bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -172,12 +172,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] -name = "ansi_term" -version = "0.12.1" +name = "anstream" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ - "winapi 0.3.9", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", ] [[package]] @@ -186,6 +192,34 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys 0.59.0", +] + [[package]] name = "anyhow" version = "1.0.92" @@ -533,17 +567,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi 0.3.9", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -1227,21 +1250,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.5.0" @@ -1249,6 +1257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", + "clap_derive", ] [[package]] @@ -1257,8 +1266,22 @@ version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ + "anstream", "anstyle", "clap_lex", + "strsim 0.11.1", +] + +[[package]] +name = "clap_derive" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -1346,6 +1369,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "com" version = "0.6.0" @@ -1718,7 +1747,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.0", + "clap", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -3808,6 +3837,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -3825,15 +3860,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -4377,7 +4403,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "windows-sys 0.48.0", ] @@ -4403,11 +4429,17 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -4935,7 +4967,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "wasi", "windows-sys 0.52.0", @@ -4946,6 +4978,7 @@ name = "mizer" version = "0.1.0" dependencies = [ "anyhow", + "clap", "coremidi-hotplug-notification", "criterion", "dashmap", @@ -5003,7 +5036,6 @@ dependencies = [ "sentry-tracing", "serde", "spin_sleep", - "structopt", "test-case", "tokio", "tracing", @@ -9498,12 +9530,6 @@ dependencies = [ "float-cmp", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.9.3" @@ -9517,28 +9543,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap 2.34.0", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" +name = "strsim" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -9991,15 +9999,6 @@ dependencies = [ "test-case-core", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thin-vec" version = "0.2.13" @@ -10758,6 +10757,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "0.6.5" diff --git a/crates/mizer/Cargo.toml b/crates/mizer/Cargo.toml index b2611fa13..7e057eede 100644 --- a/crates/mizer/Cargo.toml +++ b/crates/mizer/Cargo.toml @@ -32,7 +32,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] } tracing-appender = "0.2" tracing = "0.1" anyhow = "1" -structopt = "0.3" +clap = { version = "4.5", features = ["derive"] } metrics = "0.24" mizer-console = { path = "../components/console" } mizer-media = { path = "../components/media" } diff --git a/crates/mizer/src/flags.rs b/crates/mizer/src/flags.rs index d80d8b829..fa99ddee9 100644 --- a/crates/mizer/src/flags.rs +++ b/crates/mizer/src/flags.rs @@ -1,21 +1,22 @@ use std::path::PathBuf; -use structopt::StructOpt; +use clap::Parser; -#[derive(StructOpt, Debug, Clone, Default)] +#[derive(Parser, Debug, Clone, Default)] +#[command(version, about)] pub struct Flags { - #[structopt(long)] + #[arg(long)] pub generate_graph: bool, - #[structopt(name = "FILE", parse(from_os_str))] + #[arg(name = "FILE")] pub file: Option, /// Open the debug ui #[cfg(feature = "debug-ui")] - #[structopt(long)] + #[arg(long)] pub debug: bool, /// Join an existing session or start a new session - #[structopt(long)] + #[arg(long)] pub join: bool, #[cfg(feature = "ui")] - #[structopt(long)] + #[arg(long)] pub headless: bool, } diff --git a/crates/mizer/src/main.rs b/crates/mizer/src/main.rs index 4652c44e9..315506a6e 100644 --- a/crates/mizer/src/main.rs +++ b/crates/mizer/src/main.rs @@ -1,7 +1,6 @@ #![windows_subsystem = "windows"] use std::sync::mpsc; - -use structopt::StructOpt; +use clap::Parser; use mizer::{build_runtime, Api, Flags}; use mizer_api::handlers::Handlers; @@ -61,7 +60,7 @@ fn run_headless(flags: Flags) -> anyhow::Result<()> { fn init() -> anyhow::Result<(Flags, LoggingGuard)> { mizer_util::tracing::init(); - let flags = Flags::from_args(); + let flags = Flags::parse(); let guard = logger::init(&flags)?; tracing::debug!("flags: {:?}", flags); init_ffmpeg()?;