Skip to content

Commit

Permalink
fix(help)!: Make DeriveDisplayOrder the default, removing it
Browse files Browse the repository at this point in the history
Force sorting with `next_display_order(None)`

Fixes clap-rs#2808
  • Loading branch information
epage committed Jul 22, 2022
1 parent 0e448c1 commit 52983d6
Show file tree
Hide file tree
Showing 44 changed files with 953 additions and 1,031 deletions.
11 changes: 6 additions & 5 deletions CHANGELOG.md
Expand Up @@ -10,11 +10,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Breaking Changes

- `ErrorKind::EmptyValue` replaced with `ErrorKind::InvalidValue`
- `ErrorKind::UnrecognizedSubcommand` replaced with `ErrorKind::InvalidSubcommand`
- `arg!` now sets `ArgAction::SetTrue`, `ArgAction::Count`, `ArgAction::Set`, or `ArgAction::Append` as appropriate
- *(help)* Subcommand display order respects `Command::next_display_order` instead of `DeriveDisplayOrder` and using its own initial display order value
- *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag
- *(derive)* `subcommand_required(true).arg_required_else_help(true)` is set instead of `SubcommandRequiredElseHelp`
- `ErrorKind::UnrecognizedSubcommand` replaced with `ErrorKind::InvalidSubcommand` (#3676)
- `arg!` now sets `ArgAction::SetTrue`, `ArgAction::Count`, `ArgAction::Set`, or `ArgAction::Append` as appropriate (#3795)
- *(help)* Make `DeriveDisplayOrder` the default and removed the setting. To sort help, set `next_display_order(None)` (#2808)
- *(help)* Subcommand display order respects `Command::next_display_order` instead of `DeriveDisplayOrder` and using its own initial display order value (#2808)
- *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag (#3776)
- *(derive)* `subcommand_required(true).arg_required_else_help(true)` is set instead of `SubcommandRequiredElseHelp` (#3280)

### Features

Expand Down
2 changes: 1 addition & 1 deletion examples/cargo-example-derive.md
Expand Up @@ -26,8 +26,8 @@ USAGE:
cargo example-derive [OPTIONS]

OPTIONS:
-h, --help Print help information
--manifest-path <MANIFEST_PATH>
-h, --help Print help information
-V, --version Print version information

```
Expand Down
2 changes: 1 addition & 1 deletion examples/cargo-example.md
Expand Up @@ -26,8 +26,8 @@ USAGE:
cargo example [OPTIONS]

OPTIONS:
-h, --help Print help information
--manifest-path <PATH>
-h, --help Print help information
-V, --version Print version information

```
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.md
Expand Up @@ -7,9 +7,9 @@ USAGE:
demo[EXE] [OPTIONS] --name <NAME>

OPTIONS:
-n, --name <NAME> Name of the person to greet
-c, --count <COUNT> Number of times to greet [default: 1]
-h, --help Print help information
-n, --name <NAME> Name of the person to greet
-V, --version Print version information

$ demo --name Me
Expand Down
2 changes: 1 addition & 1 deletion examples/derive_ref/custom-bool.md
Expand Up @@ -14,8 +14,8 @@ ARGS:
<BOOM> [possible values: true, false]

OPTIONS:
--bar <BAR> [default: false]
--foo <FOO> [possible values: true, false]
--bar <BAR> [default: false]
-h, --help Print help information
-V, --version Print version information

Expand Down
2 changes: 1 addition & 1 deletion examples/derive_ref/interop_tests.md
Expand Up @@ -107,8 +107,8 @@ USAGE:
interop_hand_subcommand[EXE] [OPTIONS] <SUBCOMMAND>

OPTIONS:
-h, --help Print help information
-t, --top-level
-h, --help Print help information

SUBCOMMANDS:
add
Expand Down
2 changes: 1 addition & 1 deletion examples/escaped-positional-derive.md
Expand Up @@ -16,8 +16,8 @@ ARGS:

OPTIONS:
-f
-h, --help Print help information
-p <PEAR>
-h, --help Print help information
-V, --version Print version information

```
Expand Down
2 changes: 1 addition & 1 deletion examples/escaped-positional.md
Expand Up @@ -16,8 +16,8 @@ ARGS:

OPTIONS:
-f
-h, --help Print help information
-p <PEAR>
-h, --help Print help information
-V, --version Print version information

```
Expand Down
4 changes: 2 additions & 2 deletions examples/git-derive.md
Expand Up @@ -85,8 +85,8 @@ USAGE:
git-derive[EXE] stash <SUBCOMMAND>

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

SUBCOMMANDS:
push
Expand All @@ -101,8 +101,8 @@ USAGE:
git-derive[EXE] stash push [OPTIONS]

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

$ git-derive stash pop -h
git-stash-pop
Expand Down
4 changes: 2 additions & 2 deletions examples/git.md
Expand Up @@ -83,8 +83,8 @@ USAGE:
git[EXE] stash <SUBCOMMAND>

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

SUBCOMMANDS:
push
Expand All @@ -99,8 +99,8 @@ USAGE:
git[EXE] stash push [OPTIONS]

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

$ git stash pop -h
git-stash-pop
Expand Down
2 changes: 1 addition & 1 deletion examples/multicall-busybox.md
Expand Up @@ -31,8 +31,8 @@ USAGE:
busybox [OPTIONS] [APPLET]

OPTIONS:
-h, --help Print help information
--install <install> Install hardlinks for all subcommands in path
-h, --help Print help information

APPLETS:
true does nothing successfully
Expand Down
4 changes: 2 additions & 2 deletions examples/pacman.md
Expand Up @@ -62,9 +62,9 @@ ARGS:
<package>... packages

OPTIONS:
-h, --help Print help information
-i, --info view package information
-s, --search <search>... search remote repositories for matching strings
-i, --info view package information
-h, --help Print help information

```

Expand Down
3 changes: 1 addition & 2 deletions examples/tutorial_builder/02_app_settings.rs
@@ -1,8 +1,7 @@
use clap::{arg, command, AppSettings, ArgAction};
use clap::{arg, command, ArgAction};

fn main() {
let matches = command!() // requires `cargo` feature
.global_setting(AppSettings::DeriveDisplayOrder)
.allow_negative_numbers(true)
.arg(arg!(--two <VALUE>).action(ArgAction::Set))
.arg(arg!(--one <VALUE>).action(ArgAction::Set))
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial_builder/02_apps.md
Expand Up @@ -8,9 +8,9 @@ USAGE:
02_apps[EXE] --two <VALUE> --one <VALUE>

OPTIONS:
-h, --help Print help information
--one <VALUE>
--two <VALUE>
--one <VALUE>
-h, --help Print help information
-V, --version Print version information

$ 02_apps --version
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial_builder/02_crate.md
Expand Up @@ -7,9 +7,9 @@ USAGE:
02_crate[EXE] --two <VALUE> --one <VALUE>

OPTIONS:
-h, --help Print help information
--one <VALUE>
--two <VALUE>
--one <VALUE>
-h, --help Print help information
-V, --version Print version information

$ 02_crate --version
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_builder/03_01_flag_bool.md
Expand Up @@ -7,8 +7,8 @@ USAGE:
03_01_flag_bool[EXE] [OPTIONS]

OPTIONS:
-h, --help Print help information
-v, --verbose
-h, --help Print help information
-V, --version Print version information

$ 03_01_flag_bool
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_builder/03_01_flag_count.md
Expand Up @@ -7,8 +7,8 @@ USAGE:
03_01_flag_count[EXE] [OPTIONS]

OPTIONS:
-h, --help Print help information
-v, --verbose
-h, --help Print help information
-V, --version Print version information

$ 03_01_flag_count
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_builder/03_02_option.md
Expand Up @@ -7,8 +7,8 @@ USAGE:
03_02_option[EXE] [OPTIONS]

OPTIONS:
-h, --help Print help information
-n, --name <NAME>
-h, --help Print help information
-V, --version Print version information

$ 03_02_option
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorial_builder/04_03_relations.md
Expand Up @@ -10,13 +10,13 @@ ARGS:
<INPUT_FILE> some regular input

OPTIONS:
-c <CONFIG>
-h, --help Print help information
--set-ver <VER> set version manually
--major auto inc major
--minor auto inc minor
--patch auto inc patch
--set-ver <VER> set version manually
--spec-in <SPEC_IN> some special input argument
-c <CONFIG>
-h, --help Print help information
-V, --version Print version information

$ 04_03_relations
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorial_builder/04_04_custom.md
Expand Up @@ -10,13 +10,13 @@ ARGS:
<INPUT_FILE> some regular input

OPTIONS:
-c <CONFIG>
-h, --help Print help information
--set-ver <VER> set version manually
--major auto inc major
--minor auto inc minor
--patch auto inc patch
--set-ver <VER> set version manually
--spec-in <SPEC_IN> some special input argument
-c <CONFIG>
-h, --help Print help information
-V, --version Print version information

$ 04_04_custom
Expand Down
3 changes: 1 addition & 2 deletions examples/tutorial_derive/02_app_settings.rs
@@ -1,9 +1,8 @@
use clap::{AppSettings, Parser};
use clap::Parser;

#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(allow_negative_numbers = true)]
#[clap(global_setting(AppSettings::DeriveDisplayOrder))]
struct Cli {
#[clap(long, value_parser)]
two: String,
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial_derive/02_apps.md
Expand Up @@ -8,9 +8,9 @@ USAGE:
02_apps[EXE] --two <VALUE> --one <VALUE>

OPTIONS:
-h, --help Print help information
--one <VALUE>
--two <VALUE>
--one <VALUE>
-h, --help Print help information
-V, --version Print version information

$ 02_apps --version
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial_derive/02_crate.md
Expand Up @@ -7,9 +7,9 @@ USAGE:
02_crate[EXE] --two <VALUE> --one <VALUE>

OPTIONS:
-h, --help Print help information
--one <VALUE>
--two <VALUE>
--one <VALUE>
-h, --help Print help information
-V, --version Print version information

$ 02_crate --version
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_derive/03_01_flag_bool.md
Expand Up @@ -7,8 +7,8 @@ USAGE:
03_01_flag_bool[EXE] [OPTIONS]

OPTIONS:
-h, --help Print help information
-v, --verbose
-h, --help Print help information
-V, --version Print version information

$ 03_01_flag_bool
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_derive/03_01_flag_count.md
Expand Up @@ -7,8 +7,8 @@ USAGE:
03_01_flag_count[EXE] [OPTIONS]

OPTIONS:
-h, --help Print help information
-v, --verbose
-h, --help Print help information
-V, --version Print version information

$ 03_01_flag_count
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_derive/03_02_option.md
Expand Up @@ -7,8 +7,8 @@ USAGE:
03_02_option[EXE] [OPTIONS]

OPTIONS:
-h, --help Print help information
-n, --name <NAME>
-h, --help Print help information
-V, --version Print version information

$ 03_02_option
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorial_derive/04_03_relations.md
Expand Up @@ -10,13 +10,13 @@ ARGS:
<INPUT_FILE> some regular input

OPTIONS:
-c <CONFIG>
-h, --help Print help information
--set-ver <VER> set version manually
--major auto inc major
--minor auto inc minor
--patch auto inc patch
--set-ver <VER> set version manually
--spec-in <SPEC_IN> some special input argument
-c <CONFIG>
-h, --help Print help information
-V, --version Print version information

$ 04_03_relations
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorial_derive/04_04_custom.md
Expand Up @@ -10,13 +10,13 @@ ARGS:
<INPUT_FILE> some regular input

OPTIONS:
-c <CONFIG>
-h, --help Print help information
--set-ver <VER> set version manually
--major auto inc major
--minor auto inc minor
--patch auto inc patch
--set-ver <VER> set version manually
--spec-in <SPEC_IN> some special input argument
-c <CONFIG>
-h, --help Print help information
-V, --version Print version information

$ 04_04_custom
Expand Down
6 changes: 3 additions & 3 deletions examples/typed-derive.md
Expand Up @@ -9,12 +9,12 @@ USAGE:
typed-derive[EXE] [OPTIONS]

OPTIONS:
-O <OPTIMIZATION> Implicitly using `std::str::FromStr`
-I <DIR> Allow invalid UTF-8 paths
--bind <BIND> Handle IP addresses
--sleep <SLEEP> Allow human-readable durations
-D <DEFINES> Hand-written parser for tuples
-h, --help Print help information
-I <DIR> Allow invalid UTF-8 paths
-O <OPTIMIZATION> Implicitly using `std::str::FromStr`
--sleep <SLEEP> Allow human-readable durations

```

Expand Down

0 comments on commit 52983d6

Please sign in to comment.