Skip to content

Commit

Permalink
fix!: Remove unstable-v4 feature gate
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 22, 2022
1 parent 982d4ca commit 46532d3
Show file tree
Hide file tree
Showing 129 changed files with 354 additions and 6,155 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Expand Up @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## 4.0.0 - Upcoming

_gated behind `unstable-v4`_

### Breaking Changes

- `Error::EmptyValue` replaced with `Error::InvalidValue`
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -79,8 +79,8 @@ unicode = ["textwrap/unicode-width", "unicase"] # Support for unicode character
# In-work features
unstable-replace = []
unstable-grouped = []
# note: this will always enable clap_derive, change this to `clap_derive?/unstable-v4` when MSRV is bigger than 1.60
unstable-v4 = ["clap_derive/unstable-v4", "deprecated"]
# note: this will always enable clap_derive, change this to `clap_derive?/unstable-v5` when MSRV is bigger than 1.60
unstable-v5 = ["clap_derive/unstable-v5", "deprecated"]

[lib]
bench = false
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -17,7 +17,7 @@ _FEATURES_minimal = --no-default-features --features "std"
_FEATURES_default =
_FEATURES_wasm = --features "deprecated derive cargo env unicode unstable-replace unstable-grouped"
_FEATURES_full = --features "deprecated derive cargo env unicode unstable-replace unstable-grouped wrap_help"
_FEATURES_next = ${_FEATURES_full} --features unstable-v4
_FEATURES_next = ${_FEATURES_full} --features unstable-v5
_FEATURES_debug = ${_FEATURES_full} --features debug
_FEATURES_release = ${_FEATURES_full} --release

Expand Down
2 changes: 1 addition & 1 deletion clap_derive/Cargo.toml
Expand Up @@ -49,6 +49,6 @@ proc-macro-error = "1"
[features]
default = []
debug = []
unstable-v4 = ["deprecated"]
unstable-v5 = ["deprecated"]
deprecated = []
raw-deprecated = ["deprecated"]
17 changes: 2 additions & 15 deletions clap_derive/src/attrs.rs
Expand Up @@ -750,16 +750,10 @@ impl Attrs {
quote!( #(#next_help_heading)* #(#help_heading)* )
}

#[cfg(feature = "unstable-v4")]
pub fn id(&self) -> TokenStream {
self.name.clone().raw()
}

#[cfg(not(feature = "unstable-v4"))]
pub fn id(&self) -> TokenStream {
self.cased_name()
}

pub fn cased_name(&self) -> TokenStream {
self.name.clone().translate(*self.casing)
}
Expand All @@ -780,7 +774,7 @@ impl Attrs {
let inner_type = inner_type(field_type);
let span = action.span();
default_value_parser(inner_type, span)
} else if !self.ignore_parser() || cfg!(not(feature = "unstable-v4")) {
} else if !self.ignore_parser() {
self.parser(field_type).value_parser()
} else {
let inner_type = inner_type(field_type);
Expand All @@ -802,7 +796,7 @@ impl Attrs {
if let Some(value_parser) = self.value_parser.as_ref() {
let span = value_parser.span();
default_action(field_type, span)
} else if !self.ignore_parser() || cfg!(not(feature = "unstable-v4")) {
} else if !self.ignore_parser() {
self.parser(field_type).action()
} else {
let span = self
Expand All @@ -815,16 +809,10 @@ impl Attrs {
})
}

#[cfg(feature = "unstable-v4")]
pub fn ignore_parser(&self) -> bool {
self.parser.is_none()
}

#[cfg(not(feature = "unstable-v4"))]
pub fn ignore_parser(&self) -> bool {
self.value_parser.is_some() || self.action.is_some()
}

pub fn explicit_parser(&self) -> bool {
self.parser.is_some()
}
Expand Down Expand Up @@ -1200,7 +1188,6 @@ pub enum Name {
}

impl Name {
#[cfg(feature = "unstable-v4")]
pub fn raw(self) -> TokenStream {
match self {
Name::Assigned(tokens) => tokens,
Expand Down
16 changes: 4 additions & 12 deletions clap_derive/src/derives/subcommand.rs
Expand Up @@ -484,17 +484,9 @@ fn gen_from_arg_matches(
Unnamed(..) => abort_call_site!("{}: tuple enums are not supported", variant.ident),
};

if cfg!(feature = "unstable-v4") {
quote! {
if #sub_name == #subcommand_name_var && !#sub_arg_matches_var.contains_id("") {
return ::std::result::Result::Ok(#name :: #variant_name #constructor_block)
}
}
} else {
quote! {
if #sub_name == #subcommand_name_var {
return ::std::result::Result::Ok(#name :: #variant_name #constructor_block)
}
quote! {
if #sub_name == #subcommand_name_var && !#sub_arg_matches_var.contains_id("") {
return ::std::result::Result::Ok(#name :: #variant_name #constructor_block)
}
}
});
Expand Down Expand Up @@ -528,7 +520,7 @@ fn gen_from_arg_matches(
.chain(
#sub_arg_matches_var
.remove_many::<#str_ty>("")
.into_iter().flatten() // `""` isn't present, bug in `unstable-v4`
.unwrap()
.map(#str_ty::from)
)
.collect::<::std::vec::Vec<_>>()
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.md
Expand Up @@ -4,7 +4,7 @@ clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser

USAGE:
demo[EXE] [OPTIONS] --name <NAME>
demo [OPTIONS] --name <NAME>

OPTIONS:
-c, --count <COUNT> Number of times to greet [default: 1]
Expand Down
4 changes: 2 additions & 2 deletions examples/derive_ref/custom-bool.md
Expand Up @@ -8,7 +8,7 @@ clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser

USAGE:
custom-bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
custom-bool [OPTIONS] --foo <FOO> <BOOM>

ARGS:
<BOOM> [possible values: true, false]
Expand All @@ -26,7 +26,7 @@ error: The following required arguments were not provided:
<BOOM>

USAGE:
custom-bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
custom-bool [OPTIONS] --foo <FOO> <BOOM>

For more information try --help

Expand Down
16 changes: 8 additions & 8 deletions examples/derive_ref/interop_tests.md
Expand Up @@ -40,7 +40,7 @@ error: Found argument '--unknown' which wasn't expected, or isn't valid in this
If you tried to supply `--unknown` as a value rather than a flag, use `-- --unknown`

USAGE:
interop_augment_args[EXE] [OPTIONS]
interop_augment_args [OPTIONS]

For more information try --help

Expand Down Expand Up @@ -78,7 +78,7 @@ error: Found argument '--unknown' which wasn't expected, or isn't valid in this
If you tried to supply `--unknown` as a value rather than a flag, use `-- --unknown`

USAGE:
interop_augment_subcommands[EXE] derived [OPTIONS]
interop_augment_subcommands derived [OPTIONS]

For more information try --help

Expand All @@ -90,7 +90,7 @@ $ interop_augment_subcommands unknown
error: Found argument 'unknown' which wasn't expected, or isn't valid in this context

USAGE:
interop_augment_subcommands[EXE] [SUBCOMMAND]
interop_augment_subcommands [SUBCOMMAND]

For more information try --help

Expand All @@ -101,10 +101,10 @@ For more information try --help
```console
$ interop_hand_subcommand
? failed
error: 'interop_hand_subcommand[EXE]' requires a subcommand but one was not provided
error: 'interop_hand_subcommand' requires a subcommand but one was not provided

USAGE:
interop_hand_subcommand[EXE] [OPTIONS] <SUBCOMMAND>
interop_hand_subcommand [OPTIONS] <SUBCOMMAND>

For more information try --help

Expand Down Expand Up @@ -148,7 +148,7 @@ error: Found argument '--unknown' which wasn't expected, or isn't valid in this
If you tried to supply `--unknown` as a value rather than a flag, use `-- --unknown`

USAGE:
interop_hand_subcommand[EXE] add [NAME]...
interop_hand_subcommand add [NAME]...

For more information try --help

Expand Down Expand Up @@ -192,7 +192,7 @@ $ interop_hand_subcommand unknown
error: Found argument 'unknown' which wasn't expected, or isn't valid in this context

USAGE:
interop_hand_subcommand[EXE] [OPTIONS] <SUBCOMMAND>
interop_hand_subcommand [OPTIONS] <SUBCOMMAND>

For more information try --help

Expand Down Expand Up @@ -249,7 +249,7 @@ error: Found argument '--unknown' which wasn't expected, or isn't valid in this
If you tried to supply `--unknown` as a value rather than a flag, use `-- --unknown`

USAGE:
interop_flatten_hand_args[EXE] [OPTIONS]
interop_flatten_hand_args [OPTIONS]

For more information try --help

Expand Down
4 changes: 2 additions & 2 deletions examples/escaped-positional-derive.md
Expand Up @@ -9,7 +9,7 @@ clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser

USAGE:
escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
escaped-positional-derive [OPTIONS] [-- <SLOP>...]

ARGS:
<SLOP>...
Expand Down Expand Up @@ -38,7 +38,7 @@ $ escaped-positional-derive foo bar
error: Found argument 'foo' which wasn't expected, or isn't valid in this context

USAGE:
escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
escaped-positional-derive [OPTIONS] [-- <SLOP>...]

For more information try --help

Expand Down
4 changes: 2 additions & 2 deletions examples/escaped-positional.md
Expand Up @@ -9,7 +9,7 @@ clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser

USAGE:
escaped-positional[EXE] [OPTIONS] [-- <SLOP>...]
escaped-positional [OPTIONS] [-- <SLOP>...]

ARGS:
<SLOP>...
Expand Down Expand Up @@ -38,7 +38,7 @@ $ escaped-positional foo bar
error: Found argument 'foo' which wasn't expected, or isn't valid in this context

USAGE:
escaped-positional[EXE] [OPTIONS] [-- <SLOP>...]
escaped-positional [OPTIONS] [-- <SLOP>...]

For more information try --help

Expand Down
26 changes: 13 additions & 13 deletions examples/git-derive.md
Expand Up @@ -10,7 +10,7 @@ git
A fictional versioning CLI

USAGE:
git-derive[EXE] <SUBCOMMAND>
git-derive <SUBCOMMAND>

OPTIONS:
-h, --help Print help information
Expand All @@ -27,7 +27,7 @@ git
A fictional versioning CLI

USAGE:
git-derive[EXE] <SUBCOMMAND>
git-derive <SUBCOMMAND>

OPTIONS:
-h, --help Print help information
Expand All @@ -40,11 +40,11 @@ SUBCOMMANDS:
stash

$ git-derive help add
git-derive[EXE]-add
git-add
adds things

USAGE:
git-derive[EXE] add <PATH>...
git-derive add <PATH>...

ARGS:
<PATH>... Stuff to add
Expand All @@ -58,11 +58,11 @@ A basic argument:
```console
$ git-derive add
? failed
git-derive[EXE]-add
git-add
adds things

USAGE:
git-derive[EXE] add <PATH>...
git-derive add <PATH>...

ARGS:
<PATH>... Stuff to add
Expand All @@ -78,11 +78,11 @@ Adding ["Cargo.toml", "Cargo.lock"]
Default subcommand:
```console
$ git-derive stash -h
git-derive[EXE]-stash
git-stash

USAGE:
git-derive[EXE] stash [OPTIONS]
git-derive[EXE] stash <SUBCOMMAND>
git-derive stash [OPTIONS]
git-derive stash <SUBCOMMAND>

OPTIONS:
-h, --help Print help information
Expand All @@ -95,20 +95,20 @@ SUBCOMMANDS:
push

$ git-derive stash push -h
git-derive[EXE]-stash-push
git-stash-push

USAGE:
git-derive[EXE] stash push [OPTIONS]
git-derive stash push [OPTIONS]

OPTIONS:
-h, --help Print help information
-m, --message <MESSAGE>

$ git-derive stash pop -h
git-derive[EXE]-stash-pop
git-stash-pop

USAGE:
git-derive[EXE] stash pop [STASH]
git-derive stash pop [STASH]

ARGS:
<STASH>
Expand Down

0 comments on commit 46532d3

Please sign in to comment.