From e63760e461fdac8b23ac04cf8e58e9055bffa226 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Sun, 17 Oct 2021 16:58:58 +0100 Subject: [PATCH 1/2] Allow possible_values to take string vector reference Makes it more backward compatible and flexible --- src/build/arg/arg_value.rs | 6 ++++++ tests/require.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/build/arg/arg_value.rs b/src/build/arg/arg_value.rs index 7fbb5dbe..88757716 100644 --- a/src/build/arg/arg_value.rs +++ b/src/build/arg/arg_value.rs @@ -38,6 +38,12 @@ impl<'help> From<&'help str> for ArgValue<'help> { } } +impl<'help> From<&'help &'help str> for ArgValue<'help> { + fn from(s: &'help &'help str) -> Self { + Self::new(s) + } +} + /// Getters impl<'help> ArgValue<'help> { /// Get the name of the argument value diff --git a/tests/require.rs b/tests/require.rs index 79442116..5fb2fb08 100644 --- a/tests/require.rs +++ b/tests/require.rs @@ -711,7 +711,7 @@ fn required_if_val_present_fail_error_output() { Arg::new("target") .takes_value(true) .required(true) - .possible_values(["file", "stdout"]) + .possible_values(&["file", "stdout"]) .long("target"), ) .arg( From 585e9958110251f33a47a58d96ab94eef5298a79 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Sun, 17 Oct 2021 17:00:58 +0100 Subject: [PATCH 2/2] Release 3.0.0-beta.5 --- .github/workflows/ci.yml | 4 +- CHANGELOG.md | 86 +++++++++++++++++++++++++++++++----- Cargo.toml | 4 +- README.md | 17 ++++--- clap_derive/Cargo.toml | 2 +- clap_derive/src/lib.rs | 2 +- clap_generate/Cargo.toml | 4 +- clap_generate/src/lib.rs | 2 +- clap_generate_fig/Cargo.toml | 6 +-- clap_generate_fig/src/lib.rs | 2 +- clap_up/src/lib.rs | 1 + src/lib.rs | 2 +- 12 files changed, 97 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3d5f8a9..2b0f5e3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: if: matrix.features == 'none' with: command: test - args: --target ${{ matrix.target }} --no-default-features --features "std cargo" -p clap:3.0.0-beta.4 + args: --target ${{ matrix.target }} --no-default-features --features "std cargo" -p clap:3.0.0-beta.5 - name: Test all features uses: actions-rs/cargo@v1 if: matrix.features == 'all' @@ -133,7 +133,7 @@ jobs: if: matrix.features == 'none' with: command: test - args: --no-default-features --features "std cargo" -p clap:3.0.0-beta.4 + args: --no-default-features --features "std cargo" -p clap:3.0.0-beta.5 - name: Test all features uses: actions-rs/cargo@v1 if: matrix.features == 'all' diff --git a/CHANGELOG.md b/CHANGELOG.md index fef42305..ec8891c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,84 @@ TODO: `YamlLoader` ## v3.0.0-rc.0 + + +## v3.0.0-beta.5 (2021-10-18) + #### BREAKING CHANGES * **Renamed Features** * `unicode_help` to `unicode` to encompass more functionality -* **Gated Features** +* **Gated behind features** * `App::replace` is now gated behind `unstable-replace` - +* **Removed `derive` requirement** + * `clap::ArgEnum` + * `clap::Args` + * `clap::FromArgMatches` + * `clap::IntoApp` + * `clap::Subcommand` +* **Renamed Traits** + * `clap::Clap` => `clap::Parser` +* **Renamed Methods** + * `App::generate_usage` => `App::render_usage` * **Removed Settings** - * `AppSettings::DisableVersionForSubcommands` - * `AppSettings::ColoredHelp`: we are now relying solely on the `color` feature flag and `AppSettings::Color(Auto|Always|Never)` + * `AppSettings::DisableVersionForSubcommands` is now default behaviour + * `AppSettings::ColoredHelp`: we are now relying solely on the `color` feature flag and `App::color` method + * `AppSettings::StrictUtf8` is now default behaviour + * `AppSettings::AllowInvalidUtf8` in favor of `ArgSettings::AllowInvalidUtf8` + * `AppSettings::UnifiedHelpMessage` is now default behaviour + * `AppSettings::ColorAlways` in favor of `App::color` + * `AppSettings::ColorNever` in favor of `App::color` + * `AppSettings::ColorAuto` in favor of `App::color` +* **Removed methods** + * **App** + * `App::get_flags` + * `App::get_positionals_with_no_heading` + * `App::get_flags_with_no_heading` + * `App::get_opts_with_no_heading` + * `App::stop_custom_headings` in favor of `App:help_heading(None)` + * **Error** + * `Error::with_description` in favor of `App::error` + * **ArgEnum** + * `ArgEnum::as_arg` in favor of `ArgEnum::to_arg_value` + * **clap_generate::Generator** + * `Generator::all_subcommands` + * `Generator::find_subcommand_with_path` + * `Generator::subcommands` + * `Generator::shorts_and_visible_aliases` + * `Generator::longs_and_visible_aliases` + * `Generator::flags` +* **Removed** + * `ArgEnum::VARIANTS` in favor of `ArgEnum::value_variants` +* **Deprecated** + * `clap::clap_app!` in favor of other builders +* **Changed** + * `App::get_possible_values` returns `Option<&[ArgValue]>` now + * `RegexRef` is now an enum also allowing `RegexSet` to be used + * `clap_generate::Generator::file_name` and `clap_generate::Generator::generate` now take `&self` + * `clap_generate::generate` and `clap_generate::generate_to` now takes `Generator` as first argument + +#### Features + +* **Added** + * `clap::ArgValue` to denote information about possible values for args + * `clap::ColorChoice` to specify color setting for the app +* **Added Settings** + * `AppSettings::AllowInvalidUtf8ForExternalSubcommands` + * `AppSettings::Multicall` behind `unstable-multicall` feature + * `ArgSettings::AllowInvalidUtf8` +* **Added Methods** + * **ArgEnum** + * `ArgEnum::value_variants` + * `ArgEnum::to_arg_value` + * **App** + * `App::color` + * `App::error` + * `App::get_long_about` + * `App::get_help_heading` + * **Arg** + * `Arg::is_positional` +* Allow positionals to occur multiple times ## v3.0.0-beta.4 (2021-08-14) @@ -34,7 +102,6 @@ Added `unicode_help`, `env` features. * `Arg::hide_env_values` * **ArgSettings** * `ArgSettings::HideEnvValues` - * **Removed Methods** * **Arg** * `Arg::settings` in favor of `Arg::setting(Setting1 | Setting2)` @@ -42,17 +109,11 @@ Added `unicode_help`, `env` features. * **Renamed Settings** * `AppSettings::DisableHelpFlags` => `AppSettings::DisableHelpFlag` * `AppSettings::DisableVersion` => `AppSettings::DisableVersionFlag` - * `AppSettings::VersionlessSubcommands` => `AppSettings::DisableVersionForSubcommands` + * `AppSettings::VersionlessSubcommands` => `AppSettings::DisableVersionForSubcommands` (changed again 3.0.0-beta.5) * **Renamed Variants** * **ErrorKind** * `ErrorKind::MissingArgumentOrSubcommand` => `ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand` * **Changed** - * `AppSettings::StrictUtf8` is now default and it and `AppSettings::AllowInvalidUtf8` are replaced by - * `AppSettings::AllowInvalidUtf8ForExternalSubcommands` - * This only applies to the subcommand args. Before we paniced if the - subcommand itself was invalid but now we will report an error up to the - user. - * `ArgSettings::AllowInvalidUtf8` * Allowing empty values is the default again with `ArgSettings::AllowEmptyValues` changing to `ArgSettings::ForbidEmptyValues` * `AppSettings::GlobalVersion` renamed to `AppSettings::PropagateVersion` and it is not applied @@ -78,6 +139,7 @@ Added `unicode_help`, `env` features. * **Added** * `clap_generate::Shell` + * `clap::Args` behind `derive` feature * **Added Methods** * **App** * `App::license` diff --git a/Cargo.toml b/Cargo.toml index 86993654..2239474b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clap" -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" edition = "2018" authors = [ "Kevin K. ", @@ -60,7 +60,7 @@ name = "06_rustup" path = "benches/06_rustup.rs" [dependencies] -clap_derive = { path = "./clap_derive", version = "=3.0.0-beta.4", optional = true } +clap_derive = { path = "./clap_derive", version = "=3.0.0-beta.5", optional = true } bitflags = "1.2" textwrap = { version = "0.14.0", default-features = false, features = [] } unicase = { version = "2.6", optional = true } diff --git a/README.md b/README.md index c19124bb..310dfdd8 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ It is a simple-to-use, efficient, and full-featured library for parsing command * [Questions & Discussions](https://github.com/clap-rs/clap/discussions) * [Website](https://clap.rs/) -We are currently hard at work trying to release `3.0`. We have a `3.0.0-beta.4` prerelease out but we do not give any guarantees that its API is stable. We do not have a changelog yet which will be written down after we are sure about the API stability. We recommend users to not update to the prerelease version yet and to wait for the official `3.0`. +We are currently hard at work trying to release `3.0`. We have a `3.0.0-beta.5` prerelease out but we do not give any guarantees that its API is stable. We do not have a changelog yet which will be written down after we are sure about the API stability. We recommend users to not update to the prerelease version yet and to wait for the official `3.0`. > If you're looking for the readme & examples for `clap v2.33` - find it on [github](https://github.com/clap-rs/clap/tree/v2.33.0), [crates.io](https://crates.io/crates/clap/2.33.0), [docs.rs](https://docs.rs/clap/2.33.0/clap/). @@ -28,8 +28,7 @@ We are currently hard at work trying to release `3.0`. We have a `3.0.0-beta.4` 1. [Using Derive Macros](#using-derive-macros) 2. [Using Builder Pattern](#using-builder-pattern) 3. [Using YAML](#using-yaml) - 4. [Using Macros](#using-macros) - 5. [Running it](#running-it) + 4. [Running it](#running-it) 5. [Try it!](#try-it) 1. [Pre-Built Test](#pre-built-test) 2. [Build Your Own Binary](#build-your-own-binary) @@ -126,7 +125,7 @@ Add `clap` to your `Cargo.toml` ```toml [dependencies] -clap = "3.0.0-beta.4" +clap = "3.0.0-beta.5" ``` #### Using Derive Macros @@ -350,7 +349,7 @@ Simply add the `yaml` feature flag to your `Cargo.toml`. ```toml [dependencies] -clap = { version = "3.0.0-beta.4", features = ["yaml"] } +clap = { version = "3.0.0-beta.5", features = ["yaml"] } ``` Finally we create our `main.rs` file just like we would have with the previous two examples: @@ -426,7 +425,7 @@ For full usage, add `clap` as a dependency in your `Cargo.toml` to use from crat ```toml [dependencies] -clap = "3.0.0-beta.4" +clap = "3.0.0-beta.5" ``` Define a list of valid arguments for your program (see the [documentation][docs] or [examples][examples] directory of this repo) @@ -451,7 +450,7 @@ To disable these, add this to your `Cargo.toml`: ```toml [dependencies.clap] -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" default-features = false features = ["std"] ``` @@ -460,7 +459,7 @@ You can also selectively enable only the features you'd like to include, by addi ```toml [dependencies.clap] -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" default-features = false # Cherry-pick the features you'd like to use @@ -522,7 +521,7 @@ In order to keep from being surprised of breaking changes, it is **highly** reco ```toml [dependencies] -clap = "~3.0.0-beta.4" +clap = "~3.0.0-beta.5" ``` This will cause *only* the patch version to be updated upon a `cargo update` call, and therefore cannot break due to new features, or bumped minimum versions of Rust. diff --git a/clap_derive/Cargo.toml b/clap_derive/Cargo.toml index 0bb4891e..8417d72c 100644 --- a/clap_derive/Cargo.toml +++ b/clap_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clap_derive" -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" edition = "2018" authors = [ "Guillaume Pinot ", diff --git a/clap_derive/src/lib.rs b/clap_derive/src/lib.rs index 110c87a5..41f6e21c 100644 --- a/clap_derive/src/lib.rs +++ b/clap_derive/src/lib.rs @@ -13,7 +13,7 @@ // MIT/Apache 2.0 license. #![doc(html_logo_url = "https://clap.rs/images/media/clap.png")] -#![doc(html_root_url = "https://docs.rs/clap_derive/3.0.0-beta.4")] +#![doc(html_root_url = "https://docs.rs/clap_derive/3.0.0-beta.5")] //! This crate is custom derive for clap. It should not be used //! directly. See [clap documentation](http://docs.rs/clap) diff --git a/clap_generate/Cargo.toml b/clap_generate/Cargo.toml index 0b4100a7..85122b46 100644 --- a/clap_generate/Cargo.toml +++ b/clap_generate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clap_generate" -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" edition = "2018" authors = [ "Kevin K. ", @@ -30,7 +30,7 @@ readme = "README.md" bench = false [dependencies] -clap = { path = "../", version = "=3.0.0-beta.4", default-features = false, features = ["std"] } +clap = { path = "../", version = "=3.0.0-beta.5", default-features = false, features = ["std"] } [dev-dependencies] pretty_assertions = "0.7" diff --git a/clap_generate/src/lib.rs b/clap_generate/src/lib.rs index c97804b9..49ca286a 100644 --- a/clap_generate/src/lib.rs +++ b/clap_generate/src/lib.rs @@ -6,7 +6,7 @@ // for more information. #![doc(html_logo_url = "https://clap.rs/images/media/clap.png")] -#![doc(html_root_url = "https://docs.rs/clap_generate/3.0.0-beta.4")] +#![doc(html_root_url = "https://docs.rs/clap_generate/3.0.0-beta.5")] #![doc = include_str!("../README.md")] #![deny(missing_docs, trivial_casts, unused_allocation, trivial_numeric_casts)] #![forbid(unsafe_code)] diff --git a/clap_generate_fig/Cargo.toml b/clap_generate_fig/Cargo.toml index 0b8b04d4..a9b45eb9 100644 --- a/clap_generate_fig/Cargo.toml +++ b/clap_generate_fig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clap_generate_fig" -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" edition = "2018" authors = [ "Clap Maintainers" @@ -30,8 +30,8 @@ readme = "README.md" bench = false [dependencies] -clap = { path = "../", version = "=3.0.0-beta.4" } -clap_generate = { path = "../clap_generate", version = "3.0.0-beta.4" } +clap = { path = "../", version = "=3.0.0-beta.5" } +clap_generate = { path = "../clap_generate", version = "=3.0.0-beta.5" } [dev-dependencies] pretty_assertions = "0.7" diff --git a/clap_generate_fig/src/lib.rs b/clap_generate_fig/src/lib.rs index 67935e04..01a4f125 100644 --- a/clap_generate_fig/src/lib.rs +++ b/clap_generate_fig/src/lib.rs @@ -6,7 +6,7 @@ //! Generates [Fig](https://github.com/withfig/autocomplete) completions for [`clap`](https://github.com/clap-rs/clap) based CLIs #![doc(html_logo_url = "https://clap.rs/images/media/clap.png")] -#![doc(html_root_url = "https://docs.rs/clap_generate_fig/3.0.0-beta.4")] +#![doc(html_root_url = "https://docs.rs/clap_generate_fig/3.0.0-beta.5")] #![deny(missing_docs, trivial_casts, unused_allocation, trivial_numeric_casts)] #![forbid(unsafe_code)] #![allow(clippy::needless_doctest_main)] diff --git a/clap_up/src/lib.rs b/clap_up/src/lib.rs index ffe45ae9..31249c65 100644 --- a/clap_up/src/lib.rs +++ b/clap_up/src/lib.rs @@ -72,6 +72,7 @@ pub fn runner() -> Runner { ["version_short", "mut_arg"], ["help_message", "mut_arg"], ["help_short", "mut_arg"], + ["generate_usage", "render_usage"], ], ) .rename_methods( diff --git a/src/lib.rs b/src/lib.rs index 29481d66..5f19ec0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ // notice may not be copied, modified, or distributed except according to those terms. #![doc(html_logo_url = "https://clap.rs/images/media/clap.png")] -#![doc(html_root_url = "https://docs.rs/clap/3.0.0-beta.4")] +#![doc(html_root_url = "https://docs.rs/clap/3.0.0-beta.5")] #![doc = include_str!("../README.md")] //! #![crate_type = "lib"]