From a065702205bf33a343c208092d9dec574337098a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 26 Oct 2021 09:33:59 -0500 Subject: [PATCH 1/2] docs(generate): Move derive example to generate From a users perspective, `clap_derive` is baked into `clap`. `clap_generate is an add on to `clap`. So it seems best to have all `clap_generate` examples in `clap_generate` where a user will look for them. Fixes #2939 --- clap_derive/Cargo.toml | 1 - clap_generate/Cargo.toml | 1 + {clap_derive => clap_generate}/examples/value_hints_derive.rs | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename {clap_derive => clap_generate}/examples/value_hints_derive.rs (100%) diff --git a/clap_derive/Cargo.toml b/clap_derive/Cargo.toml index 56dc9cb0308..284e33265b9 100644 --- a/clap_derive/Cargo.toml +++ b/clap_derive/Cargo.toml @@ -40,7 +40,6 @@ proc-macro-error = "1" [dev-dependencies] clap = { path = "../" } -clap_generate = { path = "../clap_generate" } trybuild = "1.0" rustversion = "1" version-sync = "0.9" diff --git a/clap_generate/Cargo.toml b/clap_generate/Cargo.toml index 4ca944ff612..324493308fb 100644 --- a/clap_generate/Cargo.toml +++ b/clap_generate/Cargo.toml @@ -36,6 +36,7 @@ clap = { path = "../", version = "=3.0.0-beta.5", default-features = false, feat [dev-dependencies] pretty_assertions = "0.7" version-sync = "0.9" +clap = { path = "../", version = "=3.0.0-beta.5", default-features = false, features = ["std", "derive"] } [features] default = [] diff --git a/clap_derive/examples/value_hints_derive.rs b/clap_generate/examples/value_hints_derive.rs similarity index 100% rename from clap_derive/examples/value_hints_derive.rs rename to clap_generate/examples/value_hints_derive.rs From bfa388420b100c941884a697856858d7f44fc878 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 23 Oct 2021 10:01:55 -0500 Subject: [PATCH 2/2] Put `grouped_values_of` behind a feature gate There is enough open work on this, we should probably not have it public yet, so putting it behind a gate. See https://github.com/clap-rs/clap/issues/2924 --- .github/workflows/ci-pr.yml | 4 ++-- .github/workflows/ci.yml | 14 +++++++------- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- Cargo.toml | 3 ++- README.md | 1 + src/parse/matches/arg_matches.rs | 1 + tests/grouped_values.rs | 2 ++ 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 83b9b199670..819a1bf2e4c 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -41,7 +41,7 @@ jobs: test-full: name: Tests (Full) env: - FLAGS: --features 'wrap_help yaml regex unstable-replace unstable-multicall' + FLAGS: --features 'wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped' strategy: fail-fast: false matrix: @@ -80,7 +80,7 @@ jobs: - name: Default features run: cargo check --all-targets - name: All features + Debug - run: cargo check --all-targets --features "wrap_help yaml regex unstable-replace unstable-multicall debug" + run: cargo check --all-targets --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped debug" - name: No features run: cargo check --all-targets --no-default-features --features "std cargo" - name: UI Tests diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b0f5e3c941..1c0e86ae987 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,19 +97,19 @@ jobs: if: matrix.features == 'all' with: command: test - args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace unstable-multicall" + args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" - name: Check debug uses: actions-rs/cargo@v1 if: matrix.features == 'all' with: command: check - args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace unstable-multicall debug" + args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped debug" - name: Test release uses: actions-rs/cargo@v1 if: matrix.features == 'release' with: command: test - args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace unstable-multicall" --release + args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" --release nightly: name: Nightly Tests strategy: @@ -139,19 +139,19 @@ jobs: if: matrix.features == 'all' with: command: test - args: --features "wrap_help yaml regex unstable-replace unstable-multicall" + args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" - name: Check debug uses: actions-rs/cargo@v1 if: matrix.features == 'all' with: command: check - args: --features "wrap_help yaml regex unstable-replace unstable-multicall debug" + args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped debug" - name: Test release uses: actions-rs/cargo@v1 if: matrix.features == 'release' with: command: test - args: --features "wrap_help yaml regex unstable-replace unstable-multicall" --release + args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" --release wasm: name: Wasm Check runs-on: ubuntu-latest @@ -172,4 +172,4 @@ jobs: uses: actions-rs/cargo@v1 with: command: check - args: --target ${{ matrix.target }} --features "yaml regex unstable-replace unstable-multicall" + args: --target ${{ matrix.target }} --features "yaml regex unstable-replace unstable-multicall unstable-grouped" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index eabb04ba1da..413e5fe5ac3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: llvm-cov - args: --features "wrap_help yaml regex unstable-replace unstable-multicall" --lcov --output-path lcov.info + args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" --lcov --output-path lcov.info - name: Coveralls uses: coverallsapp/github-action@master with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c0df22a6bd0..d76e8539579 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,7 +32,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: --features "wrap_help yaml regex unstable-replace unstable-multicall" -- -D warnings + args: --features "wrap_help yaml regex unstable-replace unstable-multicall unstable-grouped" -- -D warnings - name: Format check uses: actions-rs/cargo@v1 with: diff --git a/Cargo.toml b/Cargo.toml index a13e7260a82..78685a5d9c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,6 +118,7 @@ yaml = ["yaml-rust"] # In-work features unstable-replace = [] unstable-multicall = [] +unstable-grouped = [] [profile.test] opt-level = 1 @@ -127,7 +128,7 @@ lto = true codegen-units = 1 [package.metadata.docs.rs] -features = ["yaml", "regex", "unstable-replace", "unstable-multicall"] +features = ["yaml", "regex", "unstable-replace", "unstable-multicall", "unstable-grouped"] targets = ["x86_64-unknown-linux-gnu"] [workspace] diff --git a/README.md b/README.md index 310dfdd8513..b244167bc1c 100644 --- a/README.md +++ b/README.md @@ -478,6 +478,7 @@ These features are opt-in. But be wary that they can contain breaking changes be * **unstable-replace**: Enable [`App::replace`](https://github.com/clap-rs/clap/issues/2836) * **unstable-multicall**: Enable [`AppSettings::Multicall`](https://github.com/clap-rs/clap/issues/2861) +* **unstable-grouped**: Enable [`ArgMatches::grouped_values_of`](https://github.com/clap-rs/clap/issues/2924) ### More Information diff --git a/src/parse/matches/arg_matches.rs b/src/parse/matches/arg_matches.rs index 494f8005f91..eb694bad8c5 100644 --- a/src/parse/matches/arg_matches.rs +++ b/src/parse/matches/arg_matches.rs @@ -247,6 +247,7 @@ impl ArgMatches { } /// Placeholder documentation. + #[cfg(feature = "unstable-grouped")] pub fn grouped_values_of(&self, id: T) -> Option { #[allow(clippy::type_complexity)] let arg_values: for<'a> fn( diff --git a/tests/grouped_values.rs b/tests/grouped_values.rs index dd35ac01458..9a295d65713 100644 --- a/tests/grouped_values.rs +++ b/tests/grouped_values.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "unstable-grouped")] + mod utils; use clap::{App, AppSettings, Arg};