diff --git a/Cargo.lock b/Cargo.lock index 7eee44ad9c94..1490e9687fc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -581,6 +581,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + [[package]] name = "block-buffer" version = "0.10.3" @@ -743,25 +749,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", - "bitflags", - "clap_derive 3.2.25", + "bitflags 1.3.2", "clap_lex 0.2.4", "indexmap", "once_cell", "strsim 0.10.0", "termcolor", - "terminal_size", "textwrap", ] [[package]] name = "clap" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", - "clap_derive 4.5.3", + "clap_derive", ] [[package]] @@ -774,26 +778,14 @@ dependencies = [ "anstyle", "clap_lex 0.7.0", "strsim 0.11.0", + "terminal_size", ] [[package]] name = "clap_derive" -version = "3.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" -dependencies = [ - "heck 0.4.1", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.107", -] - -[[package]] -name = "clap_derive" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -1127,7 +1119,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a183e141d0e543fe8abc96e0f06da25e3294284239260e50f63847f549d807a" dependencies = [ "anyhow", - "clap 4.5.3", + "clap 4.5.4", "crossbeam", "crossbeam-channel", "dataview", @@ -1315,7 +1307,7 @@ dependencies = [ "byte-unit", "bytes", "chrono", - "clap 3.2.25", + "clap 4.5.4", "derivative", "derive_more", "dirs", @@ -1384,7 +1376,7 @@ version = "0.1.0" dependencies = [ "anyhow", "byte-unit", - "clap 3.2.25", + "clap 4.5.4", "derivative", "enso-build", "enso-build-base", @@ -1664,23 +1656,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] @@ -2043,7 +2024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ "base64 0.13.1", - "bitflags", + "bitflags 1.3.2", "bytes", "headers-core", "http", @@ -2272,7 +2253,7 @@ dependencies = [ "byte-unit", "bytes", "chrono", - "clap 3.2.25", + "clap 4.5.4", "data-encoding", "dependency_runner", "derivative", @@ -2386,16 +2367,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "io-lifetimes" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" -dependencies = [ - "libc", - "windows-sys 0.42.0", -] - [[package]] name = "ipnet" version = "2.7.1" @@ -2528,9 +2499,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -2552,7 +2523,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" name = "logstat" version = "0.1.0" dependencies = [ - "clap 3.2.25", + "clap 4.5.4", "enso-prelude", "lazy_static", "regex", @@ -2643,7 +2614,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfb67c6dd0fa9b00619c41c5700b6f92d5f418be49b45ddb9970fbd4569df3c8" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2698,7 +2669,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", ] @@ -2710,7 +2681,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset", @@ -2833,7 +2804,7 @@ version = "0.10.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -3141,30 +3112,6 @@ dependencies = [ "toml", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.107", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -3206,7 +3153,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d9cc634bc78768157b5cbfe988ffcd1dcba95cd2b2f03a88316c08c6d00ed63" dependencies = [ - "bitflags", + "bitflags 1.3.2", "getopts", "memchr", "unicase", @@ -3328,7 +3275,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -3544,16 +3491,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.7" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags", + "bitflags 2.5.0", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.42.0", + "windows-sys 0.52.0", ] [[package]] @@ -3719,7 +3665,7 @@ version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -3908,7 +3854,7 @@ checksum = "e5d28de0a6cb2cdd83a076f1de9d965b973ae08b244df1aa70b432946dda0f32" dependencies = [ "atty", "beef", - "bitflags", + "bitflags 1.3.2", "chrono", "clap 3.2.25", "crossbeam", @@ -4093,7 +4039,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -4155,12 +4101,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb20089a8ba2b69debd491f8d2d023761cbf196e999218c591fa1e7e15a21907" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ "rustix", - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -4168,9 +4114,6 @@ name = "textwrap" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" -dependencies = [ - "terminal_size", -] [[package]] name = "thiserror" @@ -4473,7 +4416,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e19c6ab038babee3d50c8c12ff8b910bdb2196f62278776422f50390d8e53d8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "lazy_static", "log", "nix 0.24.3", @@ -5161,7 +5104,7 @@ name = "wstest" version = "0.1.0" dependencies = [ "base64 0.13.1", - "clap 3.2.25", + "clap 4.5.4", "either", "enso-prelude", "futures", diff --git a/Cargo.toml b/Cargo.toml index 8e37263b4ebe..6658bce61612 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,6 +89,7 @@ blocks_in_conditions = "allow" # Until the issue is fixed: https://github.com/ru # !!!!!!!!!!!!!!!!!!!!!!!!!!!!! # We are tryingto maintain minimum set of dependencies. Before adding a new dependency, consult it # with the core development team. Thank you! +clap = { version = "4.5.4", features = ["derive", "env", "wrap_help", "string"] } derive-where = "1.2.7" dirs = { version = "5.0.1" } octocrab = { git = "https://github.com/enso-org/octocrab", default-features = false, features = [ diff --git a/build/build/Cargo.toml b/build/build/Cargo.toml index 0a71464cba9e..d4953d0fd09a 100644 --- a/build/build/Cargo.toml +++ b/build/build/Cargo.toml @@ -13,7 +13,7 @@ base64 = "0.13.0" bytes = { workspace = true } byte-unit = { workspace = true } chrono = { version = "0.4.19", features = ["serde"] } -clap = { version = "3.1.5", features = ["derive", "env", "wrap_help"] } +clap = { workspace = true } derivative = { workspace = true } derive_more = { workspace = true } dirs = { workspace = true } diff --git a/build/build/src/engine.rs b/build/build/src/engine.rs index 0cae667d54a6..475da4858765 100644 --- a/build/build/src/engine.rs +++ b/build/build/src/engine.rs @@ -82,7 +82,7 @@ pub async fn download_project_templates(client: reqwest::Client, enso_root: Path } /// Describe, which benchmarks should be run. -#[derive(Clone, Copy, Debug, Display, PartialEq, Eq, PartialOrd, Ord, clap::ArgEnum)] +#[derive(Clone, Copy, Debug, Display, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] pub enum Benchmarks { /// Run all SBT-exposed benchmarks. Does *not* including pure [`Benchmarks::Enso`] benchmarks. All, @@ -94,7 +94,7 @@ pub enum Benchmarks { EnsoJMH, } -#[derive(Clone, Copy, Debug, Display, PartialEq, Eq, PartialOrd, Ord, clap::ArgEnum)] +#[derive(Clone, Copy, Debug, Display, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] pub enum Tests { Scala, #[clap(alias = "stdlib")] diff --git a/build/build/src/project/wasm.rs b/build/build/src/project/wasm.rs index 3ce07e75ba9b..b577e9cc26a6 100644 --- a/build/build/src/project/wasm.rs +++ b/build/build/src/project/wasm.rs @@ -16,7 +16,7 @@ pub mod test; #[derive( - clap::ArgEnum, + clap::ValueEnum, Clone, Copy, Debug, @@ -36,7 +36,7 @@ pub enum ProfilingLevel { } #[derive( - clap::ArgEnum, + clap::ValueEnum, Clone, Copy, Debug, diff --git a/build/build/src/project/wasm/test.rs b/build/build/src/project/wasm/test.rs index a12f02809679..d4590926ee38 100644 --- a/build/build/src/project/wasm/test.rs +++ b/build/build/src/project/wasm/test.rs @@ -1,6 +1,6 @@ use crate::project::*; -use clap::ArgEnum; +use clap::ValueEnum; use ide_ci::programs::cargo; use ide_ci::programs::wasm_pack; use ide_ci::programs::WasmPack; @@ -33,7 +33,7 @@ pub const SOURCE_SUBDIRECTORIES: [&str; 4] = ["src", "benches", "examples", "tes /// Select which browser should be used to run wasm tests. /// /// In principle, wasm-pack is fine with passing multiple ones in a single call. -#[derive(ArgEnum, Clone, Copy, Debug, PartialEq, Eq)] +#[derive(ValueEnum, Clone, Copy, Debug, PartialEq, Eq)] pub enum Browser { /// Run tests in Chrome using `chromedriver`. Chrome, diff --git a/build/build/src/version.rs b/build/build/src/version.rs index 1a3b03ce22cd..b376670b8be4 100644 --- a/build/build/src/version.rs +++ b/build/build/src/version.rs @@ -274,7 +274,7 @@ where } #[derive( - clap::ArgEnum, + clap::ValueEnum, Clone, Copy, PartialEq, diff --git a/build/build/src/version/promote.rs b/build/build/src/version/promote.rs index d73593f02a29..e64310e9640a 100644 --- a/build/build/src/version/promote.rs +++ b/build/build/src/version/promote.rs @@ -12,7 +12,7 @@ use ide_ci::programs::git::Ref; /// Describes what kind of version should be generated. #[derive( - clap::ArgEnum, + clap::ValueEnum, Clone, Copy, Debug, diff --git a/build/ci_utils/Cargo.toml b/build/ci_utils/Cargo.toml index 5ca71179f596..7077b7f7d036 100644 --- a/build/ci_utils/Cargo.toml +++ b/build/ci_utils/Cargo.toml @@ -12,7 +12,7 @@ bincode = "1.3.3" byte-unit = { workspace = true } bytes = { workspace = true } chrono = { version = "0.4.19", features = ["serde"] } -clap = { version = "3.1.5", features = ["derive", "env"] } +clap = { workspace = true } data-encoding = "2.3.2" dependency_runner = "1.1.0" derivative = { workspace = true } diff --git a/build/ci_utils/src/extensions/clap.rs b/build/ci_utils/src/extensions/clap.rs index 204822a38069..d51cb6aa048b 100644 --- a/build/ci_utils/src/extensions/clap.rs +++ b/build/ci_utils/src/extensions/clap.rs @@ -7,7 +7,7 @@ use clap::Arg; /// Extensions to the `clap::Arg`, intended to be used as argument attributes. -pub trait ArgExt<'h>: Sized + 'h { +pub trait ArgExt: Sized { /// If the given value is `Some`, set it as a default. /// /// Useful primarily when presence of default value on a CLI argument depends on runtime @@ -19,7 +19,7 @@ pub trait ArgExt<'h>: Sized + 'h { self.maybe_default(f.as_ref().map(|s| s.as_str())) } - fn maybe_default_t(self, f: impl Borrow> + 'h) -> Self { + fn maybe_default_t(self, f: impl Borrow>) -> Self { let printed = f.borrow().as_ref().map(|v| v.to_string()); self.maybe_default(printed) } @@ -29,7 +29,7 @@ pub trait ArgExt<'h>: Sized + 'h { fn prefixed_env(self, prefix: impl AsRef) -> Self; } -impl<'h> ArgExt<'h> for Arg<'h> { +impl ArgExt for Arg { fn maybe_default>(self, f: impl Borrow>) -> Self { if let Some(default) = f.borrow().as_ref() { self.default_value(store_static_text(default)).required(false) @@ -40,7 +40,8 @@ impl<'h> ArgExt<'h> for Arg<'h> { fn prefixed_env(self, prefix: impl AsRef) -> Self { use heck::ToShoutySnakeCase; - let var_name = format!("{}_{}", prefix.as_ref(), self.get_id().to_shouty_snake_case()); + let var_name = + format!("{}_{}", prefix.as_ref(), self.get_id().as_str().to_shouty_snake_case()); self.env(store_static_text(var_name)) } } diff --git a/build/cli/Cargo.toml b/build/cli/Cargo.toml index 270ba4b3d9f8..e2c2adeacc24 100644 --- a/build/cli/Cargo.toml +++ b/build/cli/Cargo.toml @@ -8,7 +8,7 @@ default-run = "enso-build-cli" [dependencies] anyhow = { workspace = true } byte-unit = { workspace = true } -clap = { version = "3.2.25", features = ["derive", "env", "wrap_help"] } +clap = { workspace = true } derivative = { workspace = true } enso-build-base = { path = "../base" } enso-build = { path = "../build" } diff --git a/build/cli/src/arg.rs b/build/cli/src/arg.rs index e9328c681e27..c256b845ee76 100644 --- a/build/cli/src/arg.rs +++ b/build/cli/src/arg.rs @@ -2,11 +2,14 @@ use enso_build::prelude::*; +use clap::builder::ArgPredicate; +use clap::builder::PossibleValuesParser; +use clap::builder::TypedValueParser; use clap::Arg; -use clap::ArgEnum; use clap::Args; use clap::Parser; use clap::Subcommand; +use clap::ValueEnum; use derivative::Derivative; use enso_build_base::extensions::path::display_fmt; use ide_ci::cache; @@ -52,12 +55,12 @@ pub fn default_cache_path() -> Option { } /// Extensions to the `clap::Arg`, intended to be used as argument attributes. -pub trait ArgExt<'h>: Sized + 'h { +pub trait ArgExt: Sized { /// Allow setting argument through an environment variable prefixed with Enso Build name. fn enso_env(self) -> Self; } -impl<'h> ArgExt<'h> for Arg<'h> { +impl ArgExt for Arg { fn enso_env(self) -> Self { self.prefixed_env(ENVIRONMENT_VARIABLE_NAME_PREFIX) } @@ -162,7 +165,7 @@ pub struct Cli { /// Platform to target. Currently cross-compilation is enabled only for GUI/IDE (without /// Project Manager) on platforms where Electron Builder supports this. - #[clap(long, global = true, default_value_t = TARGET_OS, enso_env(), possible_values=[OS::Windows.as_str(), OS::Linux.as_str(), OS::MacOS.as_str()])] + #[clap(long, global = true, default_value_t = TARGET_OS, enso_env(), value_parser = possible_os_parser(&[OS::Windows, OS::Linux, OS::MacOS]))] pub target_os: OS, /// Does not check the program version requirements defined in the build-config.yaml. @@ -182,30 +185,31 @@ pub struct Cli { /// This is the CLI representation of a [crate::source::Source] for a given target. #[derive(Args, Clone, Debug, Derivative)] #[derivative(PartialEq)] +#[group(skip)] pub struct Source { /// How the given target should be acquired. - #[clap(name = Target::SOURCE_NAME, arg_enum, long, default_value_t= SourceKind::Build, + #[clap(id = Target::SOURCE_NAME, value_enum, long, default_value_t= SourceKind::Build, enso_env(), - default_value_if(Target::RUN_ID_NAME, None, Some("ci-run")), - default_value_if(Target::PATH_NAME, None, Some("local")), - default_value_if(Target::RELEASE_DESIGNATOR_NAME, None, Some("release")))] + default_value_if(Target::RUN_ID_NAME, ArgPredicate::IsPresent, Some("ci-run")), + default_value_if(Target::PATH_NAME, ArgPredicate::IsPresent, Some("local")), + default_value_if(Target::RELEASE_DESIGNATOR_NAME, ArgPredicate::IsPresent, Some("release")))] pub source: SourceKind, /// If source is `local`, this argument is used to give the path with the component. /// If missing, the default would-be output directory for this component shall be used. - #[clap(name = Target::PATH_NAME, long, default_value=Target::DEFAULT_OUTPUT_PATH, enso_env())] + #[clap(id = Target::PATH_NAME, long, default_value=Target::DEFAULT_OUTPUT_PATH, enso_env())] pub path: PathBuf, /// If source is `run`, this argument is required to provide CI run ID. /// /// `GITHUB_TOKEN` environment variable with "repo" access is required to download CI run /// artifacts. - #[clap(name = Target::RUN_ID_NAME, long, required_if_eq(Target::SOURCE_NAME, "ci-run"), enso_env())] + #[clap(id = Target::RUN_ID_NAME, long, required_if_eq(Target::SOURCE_NAME, "ci-run"), enso_env())] pub run_id: Option, /// Artifact name to be used when downloading a run artifact. If not set, the default name for /// given target will be used. - #[clap(name = Target::ARTIFACT_NAME_NAME, long, enso_env())] + #[clap(id = Target::ARTIFACT_NAME_NAME, long, enso_env())] pub artifact_name: Option, /// If source is `release`, this argument is required to identify a release with asset to @@ -225,7 +229,7 @@ pub struct Source { } /// Discriminator denoting how some target artifact should be obtained. -#[derive(ArgEnum, Clone, Copy, Debug, PartialEq, Eq)] +#[derive(ValueEnum, Clone, Copy, Debug, PartialEq, Eq)] pub enum SourceKind { /// Target will be built from the target repository's sources. Build, @@ -241,11 +245,12 @@ pub enum SourceKind { /// Strongly typed argument for an output directory of a given build target. #[derive(Args, Clone, Derivative)] +#[group(skip)] #[derivative(Debug, PartialEq)] pub struct OutputPath { /// Directory where artifacts should be placed. #[derivative(Debug(format_with = "display_fmt"))] - #[clap(name = Target::OUTPUT_PATH_NAME, long, parse(try_from_str=normalize_path), default_value = Target::DEFAULT_OUTPUT_PATH, enso_env())] + #[clap(name = Target::OUTPUT_PATH_NAME, long, value_parser(normalize_path), default_value = Target::DEFAULT_OUTPUT_PATH, enso_env())] pub output_path: PathBuf, #[derivative(Debug = "ignore", PartialEq(bound = ""))] #[allow(missing_docs)] @@ -260,16 +265,28 @@ impl AsRef for OutputPath { } #[derive(Args, Clone, Derivative)] +#[group(skip)] #[derivative(Debug, PartialEq)] pub struct BuildDescription { #[derivative(PartialEq(bound = ""))] #[clap(flatten)] pub input: Target::BuildInput, - #[clap(name = Target::UPLOAD_ARTIFACT_NAME, long, enso_env(), default_value_t = ide_ci::actions::workflow::is_in_env())] + // Cumbersome way of defining a bool argument that can take explicit value. + // See: https://github.com/clap-rs/clap/issues/1649#issuecomment-1837123432 + #[clap( + name = Target::UPLOAD_ARTIFACT_NAME, + long, + enso_env(), + default_value_t = ide_ci::actions::workflow::is_in_env(), + default_missing_value("true"), + num_args(0..=1), + action = clap::ArgAction::Set + )] pub upload_artifact: bool, } #[derive(Args, Clone, PartialEq, Derivative)] +#[group(skip)] #[derivative(Debug)] pub struct BuildJob { #[clap(flatten)] @@ -279,6 +296,7 @@ pub struct BuildJob { } #[derive(Args, Clone, PartialEq, Derivative)] +#[group(skip)] #[derivative(Debug)] pub struct WatchJob { #[clap(flatten)] @@ -286,3 +304,11 @@ pub struct WatchJob { #[clap(flatten)] pub watch_input: Target::WatchInput, } + +/// Clap parser supporting a given set of [`OS`] values. +pub fn possible_os_parser(possible_os: &[OS]) -> impl TypedValueParser { + PossibleValuesParser::new(possible_os.iter().map(|os| os.as_str())) + // Unwrap below is safe, because it is symmetric to the `as_str` conversion above, and + // we'll get only the values that were generated from the `possible_os` array. + .map(|s| s.parse::().unwrap()) +} diff --git a/build/cli/src/arg/backend.rs b/build/cli/src/arg/backend.rs index cfd43b61ff86..6762a3a1e7fb 100644 --- a/build/cli/src/arg/backend.rs +++ b/build/cli/src/arg/backend.rs @@ -12,6 +12,7 @@ use enso_build::project::backend::Backend; #[derive(Args, Clone, Debug, PartialEq)] +#[group(skip)] pub struct BuildInput { #[clap(flatten)] pub runtime: Source, @@ -39,12 +40,12 @@ pub enum Command { /// the benchmarks can execute without issues. #[clap(long, enso_env())] minimal_run: bool, - #[clap(arg_enum)] + #[clap(value_enum)] which: Vec, }, /// Run the tests. Test { - #[clap(arg_enum, required = true)] + #[clap(value_enum, required = true)] which: Vec, }, /// Run an SBT command. diff --git a/build/cli/src/arg/gui.rs b/build/cli/src/arg/gui.rs index 303db25da26f..b96acdeb0352 100644 --- a/build/cli/src/arg/gui.rs +++ b/build/cli/src/arg/gui.rs @@ -13,6 +13,7 @@ use enso_build::project::gui::Gui; source_args_hlp!(Gui, "gui", BuildInput); #[derive(Args, Clone, Copy, Debug, PartialEq)] +#[group(skip)] pub struct BuildInput {} #[derive(Subcommand, Clone, Debug, PartialEq)] diff --git a/build/cli/src/arg/ide.rs b/build/cli/src/arg/ide.rs index 658d17b3c3f4..932567cee062 100644 --- a/build/cli/src/arg/ide.rs +++ b/build/cli/src/arg/ide.rs @@ -15,6 +15,7 @@ use octocrab::models::ReleaseId; source_args_hlp!(Target, "ide", BuildInput); #[derive(Args, Clone, Debug, Derivative)] +#[group(skip)] #[derivative(PartialEq)] pub struct BuildInput { #[derivative(PartialEq(bound = ""))] diff --git a/build/cli/src/arg/release.rs b/build/cli/src/arg/release.rs index 11ed1db8e439..f8507a88d324 100644 --- a/build/cli/src/arg/release.rs +++ b/build/cli/src/arg/release.rs @@ -15,7 +15,7 @@ pub struct DeployRuntime { #[derive(Args, Clone, Copy, Debug)] pub struct Promote { /// What kind of version is to be created. - #[clap(arg_enum)] + #[clap(value_enum)] pub designation: enso_build::version::promote::Designation, } diff --git a/build/cli/src/arg/runtime.rs b/build/cli/src/arg/runtime.rs index 6bb9cd610623..a42cc1781f9f 100644 --- a/build/cli/src/arg/runtime.rs +++ b/build/cli/src/arg/runtime.rs @@ -12,6 +12,7 @@ use enso_build::project::runtime::Runtime; source_args_hlp!(Runtime, "runtime", BuildInput); #[derive(Args, Clone, Copy, Debug, PartialEq, Eq)] +#[group(skip)] pub struct BuildInput {} #[derive(Subcommand, Clone, Debug, PartialEq)] diff --git a/build/cli/src/arg/wasm.rs b/build/cli/src/arg/wasm.rs index 1ccf361e8e1d..f063f96c8027 100644 --- a/build/cli/src/arg/wasm.rs +++ b/build/cli/src/arg/wasm.rs @@ -21,7 +21,7 @@ pub enum Command { /// Which browsers should be used to run WASM tests. /// /// More than one browser can be specified. - #[clap(long, enso_env(), arg_enum, default_values_t = [Browser::Firefox])] + #[clap(long, enso_env(), value_enum, default_values_t = [Browser::Firefox])] browser: Vec, }, } diff --git a/tools/language-server/logstat/Cargo.toml b/tools/language-server/logstat/Cargo.toml index 347b07fd874e..f14ec4469273 100644 --- a/tools/language-server/logstat/Cargo.toml +++ b/tools/language-server/logstat/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Enso Team "] edition = "2021" [dependencies] -clap = { version = "3", features = ["derive"] } +clap = { workspace = true } lazy_static = { workspace = true } enso-prelude = { path = "../../../lib/rust/prelude" } regex = { workspace = true } diff --git a/tools/language-server/wstest/Cargo.toml b/tools/language-server/wstest/Cargo.toml index 4abc696c954e..6cf5d3792a7e 100644 --- a/tools/language-server/wstest/Cargo.toml +++ b/tools/language-server/wstest/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] base64 = "0.13.0" -clap = { version = "3", features = ["derive"] } +clap = { workspace = true } either = "1.7.0" futures = { workspace = true } enso-prelude = { path = "../../../lib/rust/prelude" }