mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
fix(help)!: Make DeriveDisplayOrder
the default, removing it
Force sorting with `next_display_order(None)` Fixes #2808
This commit is contained in:
parent
389ff4ff21
commit
11076a5c70
45 changed files with 973 additions and 1058 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -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
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// CLI used is from rustup 408ed84f0e50511ed44a405dd91365e5da588790
|
||||
|
||||
use clap::{AppSettings, Arg, ArgGroup, Command};
|
||||
use clap::{Arg, ArgGroup, Command};
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
pub fn build_rustup(c: &mut Criterion) {
|
||||
|
@ -26,7 +26,6 @@ fn build_cli() -> Command<'static> {
|
|||
.version("0.9.0") // Simulating
|
||||
.about("The Rust toolchain installer")
|
||||
.after_help(RUSTUP_HELP)
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.arg(
|
||||
Arg::new("verbose")
|
||||
.help("Enable verbose output")
|
||||
|
@ -67,7 +66,6 @@ fn build_cli() -> Command<'static> {
|
|||
Command::new("toolchain")
|
||||
.about("Modify or query the installed toolchains")
|
||||
.after_help(TOOLCHAIN_HELP)
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(Command::new("list").about("List installed toolchains"))
|
||||
.subcommand(
|
||||
Command::new("install")
|
||||
|
@ -104,7 +102,6 @@ fn build_cli() -> Command<'static> {
|
|||
.subcommand(
|
||||
Command::new("target")
|
||||
.about("Modify a toolchain's supported targets")
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(
|
||||
Command::new("list")
|
||||
.about("List installed and available targets")
|
||||
|
@ -138,7 +135,6 @@ fn build_cli() -> Command<'static> {
|
|||
.subcommand(
|
||||
Command::new("component")
|
||||
.about("Modify a toolchain's installed components")
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(
|
||||
Command::new("list")
|
||||
.about("List installed and available components")
|
||||
|
@ -163,7 +159,6 @@ fn build_cli() -> Command<'static> {
|
|||
Command::new("override")
|
||||
.about("Modify directory toolchain overrides")
|
||||
.after_help(OVERRIDE_HELP)
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(Command::new("list").about("List directory toolchain overrides"))
|
||||
.subcommand(
|
||||
Command::new("set")
|
||||
|
@ -246,7 +241,6 @@ fn build_cli() -> Command<'static> {
|
|||
.subcommand(
|
||||
Command::new("self")
|
||||
.about("Modify the rustup installation")
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(Command::new("update").about("Download and install updates to rustup"))
|
||||
.subcommand(
|
||||
Command::new("uninstall")
|
||||
|
@ -261,7 +255,6 @@ fn build_cli() -> Command<'static> {
|
|||
Command::new("telemetry")
|
||||
.about("rustup telemetry commands")
|
||||
.hide(true)
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(Command::new("enable").about("Enable rustup telemetry"))
|
||||
.subcommand(Command::new("disable").about("Disable rustup telemetry"))
|
||||
.subcommand(Command::new("analyze").about("Analyze stored telemetry")),
|
||||
|
|
|
@ -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
|
||||
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -16,8 +16,8 @@ ARGS:
|
|||
|
||||
OPTIONS:
|
||||
-f
|
||||
-h, --help Print help information
|
||||
-p <PEAR>
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
|
||||
```
|
||||
|
|
|
@ -16,8 +16,8 @@ ARGS:
|
|||
|
||||
OPTIONS:
|
||||
-f
|
||||
-h, --help Print help information
|
||||
-p <PEAR>
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -198,25 +198,6 @@ pub enum AppSettings {
|
|||
)]
|
||||
ArgRequiredElseHelp,
|
||||
|
||||
/// Displays the arguments and [`subcommands`] in the help message in the order that they were
|
||||
/// declared in, and not alphabetically which is the default.
|
||||
///
|
||||
/// To override the declaration order, see [`Arg::display_order`] and [`Command::display_order`].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use clap::{Command, Arg, AppSettings};
|
||||
/// Command::new("myprog")
|
||||
/// .global_setting(AppSettings::DeriveDisplayOrder)
|
||||
/// .get_matches();
|
||||
/// ```
|
||||
///
|
||||
/// [`subcommands`]: crate::Command::subcommand()
|
||||
/// [`Arg::display_order`]: crate::Arg::display_order
|
||||
/// [`Command::display_order`]: crate::Command::display_order
|
||||
DeriveDisplayOrder,
|
||||
|
||||
/// Deprecated, replaced with [`Command::dont_collapse_args_in_usage`] and
|
||||
/// [`Command::is_dont_collapse_args_in_usage_set`]
|
||||
#[cfg_attr(
|
||||
|
@ -392,7 +373,6 @@ bitflags! {
|
|||
const LEADING_HYPHEN = 1 << 16;
|
||||
const NO_POS_VALUES = 1 << 17;
|
||||
const NEXT_LINE_HELP = 1 << 18;
|
||||
const DERIVE_DISP_ORDER = 1 << 19;
|
||||
const DISABLE_COLORED_HELP = 1 << 20;
|
||||
const COLOR_ALWAYS = 1 << 21;
|
||||
const COLOR_AUTO = 1 << 22;
|
||||
|
@ -448,8 +428,6 @@ impl_settings! { AppSettings, AppFlags,
|
|||
=> Flags::DONT_DELIM_TRAIL,
|
||||
DontCollapseArgsInUsage
|
||||
=> Flags::DONT_COLLAPSE_ARGS,
|
||||
DeriveDisplayOrder
|
||||
=> Flags::DERIVE_DISP_ORDER,
|
||||
DisableColoredHelp
|
||||
=> Flags::DISABLE_COLORED_HELP,
|
||||
DisableHelpSubcommand
|
||||
|
|
|
@ -70,7 +70,7 @@ pub struct Arg<'help> {
|
|||
pub(crate) long: Option<&'help str>,
|
||||
pub(crate) aliases: Vec<(&'help str, bool)>, // (name, visible)
|
||||
pub(crate) short_aliases: Vec<(char, bool)>, // (name, visible)
|
||||
pub(crate) disp_ord: DisplayOrder,
|
||||
pub(crate) disp_ord: Option<usize>,
|
||||
pub(crate) val_names: Vec<&'help str>,
|
||||
pub(crate) num_vals: Option<usize>,
|
||||
pub(crate) max_vals: Option<usize>,
|
||||
|
@ -2411,7 +2411,7 @@ impl<'help> Arg<'help> {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
pub fn display_order(mut self, ord: usize) -> Self {
|
||||
self.disp_ord.set_explicit(ord);
|
||||
self.disp_ord = Some(ord);
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -4478,7 +4478,7 @@ impl<'help> Arg<'help> {
|
|||
}
|
||||
|
||||
pub(crate) fn get_display_order(&self) -> usize {
|
||||
self.disp_ord.get_explicit()
|
||||
self.disp_ord.unwrap_or(999)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4675,43 +4675,6 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub(crate) enum DisplayOrder {
|
||||
None,
|
||||
Implicit(usize),
|
||||
Explicit(usize),
|
||||
}
|
||||
|
||||
impl DisplayOrder {
|
||||
pub(crate) fn set_explicit(&mut self, explicit: usize) {
|
||||
*self = Self::Explicit(explicit)
|
||||
}
|
||||
|
||||
pub(crate) fn set_implicit(&mut self, implicit: usize) {
|
||||
*self = (*self).max(Self::Implicit(implicit))
|
||||
}
|
||||
|
||||
pub(crate) fn make_explicit(&mut self) {
|
||||
match *self {
|
||||
Self::None | Self::Explicit(_) => {}
|
||||
Self::Implicit(disp) => self.set_explicit(disp),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_explicit(self) -> usize {
|
||||
match self {
|
||||
Self::None | Self::Implicit(_) => 999,
|
||||
Self::Explicit(disp) => disp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DisplayOrder {
|
||||
fn default() -> Self {
|
||||
Self::None
|
||||
}
|
||||
}
|
||||
|
||||
// Flags
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
|
|
@ -176,7 +176,7 @@ impl<'help> Command<'help> {
|
|||
if let Some(current_disp_ord) = self.current_disp_ord.as_mut() {
|
||||
if !arg.is_positional() && arg.provider != ArgProvider::Generated {
|
||||
let current = *current_disp_ord;
|
||||
arg.disp_ord.set_implicit(current);
|
||||
arg.disp_ord.get_or_insert(current);
|
||||
*current_disp_ord = current + 1;
|
||||
}
|
||||
}
|
||||
|
@ -3863,7 +3863,6 @@ impl<'help> Command<'help> {
|
|||
self._propagate();
|
||||
self._check_help_and_version();
|
||||
self._propagate_global_args();
|
||||
self._derive_display_order();
|
||||
|
||||
let mut pos_counter = 1;
|
||||
let hide_pv = self.is_set(AppSettings::HidePossibleValues);
|
||||
|
@ -4376,24 +4375,6 @@ To change `help`s short, call `cmd.arg(Arg::new(\"help\")...)`.",
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn _derive_display_order(&mut self) {
|
||||
debug!("Command::_derive_display_order:{}", self.name);
|
||||
|
||||
if self.settings.is_set(AppSettings::DeriveDisplayOrder) {
|
||||
for a in self
|
||||
.args
|
||||
.args_mut()
|
||||
.filter(|a| !a.is_positional())
|
||||
.filter(|a| a.provider != ArgProvider::Generated)
|
||||
{
|
||||
a.disp_ord.make_explicit();
|
||||
}
|
||||
}
|
||||
for sc in &mut self.subcommands {
|
||||
sc._derive_display_order();
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn _render_version(&self, use_long: bool) -> String {
|
||||
debug!("Command::_render_version");
|
||||
|
||||
|
|
|
@ -29,44 +29,6 @@ OPTIONS:
|
|||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static REQUIRE_EQUALS: &str = "clap-test v1.4.8
|
||||
|
||||
USAGE:
|
||||
clap-test --opt=<FILE>
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
-o, --opt=<FILE> some
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static SKIP_POS_VALS: &str = "test 1.3
|
||||
Kevin K.
|
||||
tests stuff
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS] [arg1]
|
||||
|
||||
ARGS:
|
||||
<arg1> some pos arg
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
-o, --opt <opt> some option
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static ARG_REQUIRED_ELSE_HELP: &str = "test 1.0
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
-i, --info Provides more info
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
#[test]
|
||||
fn sub_command_negate_required() {
|
||||
Command::new("sub_command_negate")
|
||||
|
@ -163,6 +125,17 @@ fn arg_required_else_help_with_default() {
|
|||
|
||||
#[test]
|
||||
fn arg_required_else_help_error_message() {
|
||||
static ARG_REQUIRED_ELSE_HELP: &str = "test 1.0
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-i, --info Provides more info
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("test")
|
||||
.arg_required_else_help(true)
|
||||
.version("1.0")
|
||||
|
@ -310,6 +283,22 @@ fn no_bin_name() {
|
|||
|
||||
#[test]
|
||||
fn skip_possible_values() {
|
||||
static SKIP_POS_VALS: &str = "test 1.3
|
||||
Kevin K.
|
||||
tests stuff
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS] [arg1]
|
||||
|
||||
ARGS:
|
||||
<arg1> some pos arg
|
||||
|
||||
OPTIONS:
|
||||
-o, --opt <opt> some option
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("test")
|
||||
.author("Kevin K.")
|
||||
.about("tests stuff")
|
||||
|
@ -575,6 +564,17 @@ fn dont_collapse_args() {
|
|||
|
||||
#[test]
|
||||
fn require_eq() {
|
||||
static REQUIRE_EQUALS: &str = "clap-test v1.4.8
|
||||
|
||||
USAGE:
|
||||
clap-test --opt=<FILE>
|
||||
|
||||
OPTIONS:
|
||||
-o, --opt=<FILE> some
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("clap-test").version("v1.4.8").arg(
|
||||
Arg::new("opt")
|
||||
.long("opt")
|
||||
|
|
|
@ -2,32 +2,6 @@ use super::utils;
|
|||
|
||||
use clap::{arg, Arg, ArgAction, Command};
|
||||
|
||||
static SC_VISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||
Some help
|
||||
|
||||
USAGE:
|
||||
ct test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-f, --flag [aliases: v_flg, flag2, flg3]
|
||||
-h, --help Print help information
|
||||
-o, --opt <opt> [aliases: visible]
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static SC_INVISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||
Some help
|
||||
|
||||
USAGE:
|
||||
ct test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-f, --flag
|
||||
-h, --help Print help information
|
||||
-o, --opt <opt>
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
#[test]
|
||||
fn single_alias_of_option() {
|
||||
let a = Command::new("single_alias")
|
||||
|
@ -216,6 +190,19 @@ fn alias_on_a_subcommand_option() {
|
|||
|
||||
#[test]
|
||||
fn invisible_arg_aliases_help_output() {
|
||||
static SC_INVISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||
Some help
|
||||
|
||||
USAGE:
|
||||
ct test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-o, --opt <opt>
|
||||
-f, --flag
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("ct").author("Salim Afiune").subcommand(
|
||||
Command::new("test")
|
||||
.about("Some help")
|
||||
|
@ -234,6 +221,19 @@ fn invisible_arg_aliases_help_output() {
|
|||
|
||||
#[test]
|
||||
fn visible_arg_aliases_help_output() {
|
||||
static SC_VISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||
Some help
|
||||
|
||||
USAGE:
|
||||
ct test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-o, --opt <opt> [aliases: visible]
|
||||
-f, --flag [aliases: v_flg, flag2, flg3]
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("ct").author("Salim Afiune").subcommand(
|
||||
Command::new("test")
|
||||
.about("Some help")
|
||||
|
|
|
@ -2,32 +2,6 @@ use super::utils;
|
|||
|
||||
use clap::{arg, Arg, ArgAction, Command};
|
||||
|
||||
static SC_VISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||
Some help
|
||||
|
||||
USAGE:
|
||||
ct test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-f, --flag [aliases: flag1] [short aliases: a, b, 🦆]
|
||||
-h, --help Print help information
|
||||
-o, --opt <opt> [short aliases: v]
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static SC_INVISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||
Some help
|
||||
|
||||
USAGE:
|
||||
ct test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-f, --flag
|
||||
-h, --help Print help information
|
||||
-o, --opt <opt>
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
#[test]
|
||||
fn single_short_alias_of_option() {
|
||||
let a = Command::new("single_alias")
|
||||
|
@ -183,6 +157,19 @@ fn short_alias_on_a_subcommand_option() {
|
|||
|
||||
#[test]
|
||||
fn invisible_short_arg_aliases_help_output() {
|
||||
static SC_INVISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||
Some help
|
||||
|
||||
USAGE:
|
||||
ct test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-o, --opt <opt>
|
||||
-f, --flag
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("ct").author("Salim Afiune").subcommand(
|
||||
Command::new("test")
|
||||
.about("Some help")
|
||||
|
@ -201,6 +188,19 @@ fn invisible_short_arg_aliases_help_output() {
|
|||
|
||||
#[test]
|
||||
fn visible_short_arg_aliases_help_output() {
|
||||
static SC_VISIBLE_ALIAS_HELP: &str = "ct-test 1.2
|
||||
Some help
|
||||
|
||||
USAGE:
|
||||
ct test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-o, --opt <opt> [short aliases: v]
|
||||
-f, --flag [aliases: flag1] [short aliases: a, b, 🦆]
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("ct").author("Salim Afiune").subcommand(
|
||||
Command::new("test")
|
||||
.about("Some help")
|
||||
|
|
|
@ -2,111 +2,27 @@ use super::utils;
|
|||
|
||||
use std::str;
|
||||
|
||||
use clap::{AppSettings, Arg, Command};
|
||||
|
||||
static NO_DERIVE_ORDER: &str = "test 1.2
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--flag_a second flag
|
||||
--flag_b first flag
|
||||
-h, --help Print help information
|
||||
--option_a <option_a> second option
|
||||
--option_b <option_b> first option
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static UNIFIED_HELP_AND_DERIVE: &str = "test 1.2
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--flag_b first flag
|
||||
--option_b <option_b> first option
|
||||
--flag_a second flag
|
||||
--option_a <option_a> second option
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static UNIFIED_DERIVE_SC_PROP: &str = "test-sub 1.2
|
||||
|
||||
USAGE:
|
||||
test sub [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--flag_b first flag
|
||||
--option_b <option_b> first option
|
||||
--flag_a second flag
|
||||
--option_a <option_a> second option
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static UNIFIED_DERIVE_SC_PROP_EXPLICIT_ORDER: &str = "test-sub 1.2
|
||||
|
||||
USAGE:
|
||||
test sub [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--flag_a second flag
|
||||
--flag_b first flag
|
||||
--option_b <option_b> first option
|
||||
--option_a <option_a> second option
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static PREFER_USER_HELP_DERIVE_ORDER: &str = "test 1.2
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help message
|
||||
--flag_b first flag
|
||||
--flag_a second flag
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static PREFER_USER_HELP_SUBCMD_DERIVE_ORDER: &str = "test-sub 1.2
|
||||
|
||||
USAGE:
|
||||
test sub [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help message
|
||||
--flag_b first flag
|
||||
--flag_a second flag
|
||||
-V, --version Print version information
|
||||
";
|
||||
use clap::{Arg, Command};
|
||||
|
||||
#[test]
|
||||
fn no_derive_order() {
|
||||
let cmd = Command::new("test").version("1.2").args(&[
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("option_b")
|
||||
.long("option_b")
|
||||
.takes_value(true)
|
||||
.help("first option"),
|
||||
Arg::new("flag_a").long("flag_a").help("second flag"),
|
||||
Arg::new("option_a")
|
||||
.long("option_a")
|
||||
.takes_value(true)
|
||||
.help("second option"),
|
||||
]);
|
||||
static NO_DERIVE_ORDER: &str = "test 1.2
|
||||
|
||||
utils::assert_output(cmd, "test --help", NO_DERIVE_ORDER, false);
|
||||
}
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--flag_a second flag
|
||||
--flag_b first flag
|
||||
-h, --help Print help information
|
||||
--option_a <option_a> second option
|
||||
--option_b <option_b> first option
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
#[test]
|
||||
fn derive_order() {
|
||||
let cmd = Command::new("test")
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.version("1.2")
|
||||
.next_display_order(None)
|
||||
.args(&[
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("option_b")
|
||||
|
@ -120,6 +36,38 @@ fn derive_order() {
|
|||
.help("second option"),
|
||||
]);
|
||||
|
||||
utils::assert_output(cmd, "test --help", NO_DERIVE_ORDER, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn derive_order() {
|
||||
static UNIFIED_HELP_AND_DERIVE: &str = "test 1.2
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--flag_b first flag
|
||||
--option_b <option_b> first option
|
||||
--flag_a second flag
|
||||
--option_a <option_a> second option
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("test").version("1.2").args(&[
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("option_b")
|
||||
.long("option_b")
|
||||
.takes_value(true)
|
||||
.help("first option"),
|
||||
Arg::new("flag_a").long("flag_a").help("second flag"),
|
||||
Arg::new("option_a")
|
||||
.long("option_a")
|
||||
.takes_value(true)
|
||||
.help("second option"),
|
||||
]);
|
||||
|
||||
utils::assert_output(cmd, "test --help", UNIFIED_HELP_AND_DERIVE, false);
|
||||
}
|
||||
|
||||
|
@ -140,7 +88,6 @@ OPTIONS:
|
|||
";
|
||||
|
||||
let cmd = Command::new("test")
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.version("1.2")
|
||||
.next_display_order(10000)
|
||||
.arg(Arg::new("flag_a").long("flag_a").help("second flag"))
|
||||
|
@ -179,7 +126,6 @@ OPTIONS:
|
|||
";
|
||||
|
||||
let cmd = Command::new("test")
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.version("1.2")
|
||||
.next_display_order(None)
|
||||
.arg(Arg::new("flag_a").long("flag_a").help("first flag"))
|
||||
|
@ -202,47 +148,71 @@ OPTIONS:
|
|||
|
||||
#[test]
|
||||
fn derive_order_subcommand_propagate() {
|
||||
let cmd = Command::new("test")
|
||||
.global_setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(
|
||||
Command::new("sub").version("1.2").args(&[
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("option_b")
|
||||
.long("option_b")
|
||||
.takes_value(true)
|
||||
.help("first option"),
|
||||
Arg::new("flag_a").long("flag_a").help("second flag"),
|
||||
Arg::new("option_a")
|
||||
.long("option_a")
|
||||
.takes_value(true)
|
||||
.help("second option"),
|
||||
]),
|
||||
);
|
||||
static UNIFIED_DERIVE_SC_PROP: &str = "test-sub 1.2
|
||||
|
||||
USAGE:
|
||||
test sub [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--flag_b first flag
|
||||
--option_b <option_b> first option
|
||||
--flag_a second flag
|
||||
--option_a <option_a> second option
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("test").subcommand(
|
||||
Command::new("sub").version("1.2").args(&[
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("option_b")
|
||||
.long("option_b")
|
||||
.takes_value(true)
|
||||
.help("first option"),
|
||||
Arg::new("flag_a").long("flag_a").help("second flag"),
|
||||
Arg::new("option_a")
|
||||
.long("option_a")
|
||||
.takes_value(true)
|
||||
.help("second option"),
|
||||
]),
|
||||
);
|
||||
|
||||
utils::assert_output(cmd, "test sub --help", UNIFIED_DERIVE_SC_PROP, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn derive_order_subcommand_propagate_with_explicit_display_order() {
|
||||
let cmd = Command::new("test")
|
||||
.global_setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(
|
||||
Command::new("sub").version("1.2").args(&[
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("option_b")
|
||||
.long("option_b")
|
||||
.takes_value(true)
|
||||
.help("first option"),
|
||||
Arg::new("flag_a")
|
||||
.long("flag_a")
|
||||
.help("second flag")
|
||||
.display_order(0),
|
||||
Arg::new("option_a")
|
||||
.long("option_a")
|
||||
.takes_value(true)
|
||||
.help("second option"),
|
||||
]),
|
||||
);
|
||||
static UNIFIED_DERIVE_SC_PROP_EXPLICIT_ORDER: &str = "test-sub 1.2
|
||||
|
||||
USAGE:
|
||||
test sub [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--flag_a second flag
|
||||
--flag_b first flag
|
||||
--option_b <option_b> first option
|
||||
--option_a <option_a> second option
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("test").subcommand(
|
||||
Command::new("sub").version("1.2").args(&[
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("option_b")
|
||||
.long("option_b")
|
||||
.takes_value(true)
|
||||
.help("first option"),
|
||||
Arg::new("flag_a")
|
||||
.long("flag_a")
|
||||
.help("second flag")
|
||||
.display_order(0),
|
||||
Arg::new("option_a")
|
||||
.long("option_a")
|
||||
.takes_value(true)
|
||||
.help("second option"),
|
||||
]),
|
||||
);
|
||||
|
||||
utils::assert_output(
|
||||
cmd,
|
||||
|
@ -254,35 +224,54 @@ fn derive_order_subcommand_propagate_with_explicit_display_order() {
|
|||
|
||||
#[test]
|
||||
fn prefer_user_help_with_derive_order() {
|
||||
let cmd = Command::new("test")
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.version("1.2")
|
||||
.args(&[
|
||||
Arg::new("help")
|
||||
.long("help")
|
||||
.short('h')
|
||||
.help("Print help message"),
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("flag_a").long("flag_a").help("second flag"),
|
||||
]);
|
||||
static PREFER_USER_HELP_DERIVE_ORDER: &str = "test 1.2
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help message
|
||||
--flag_b first flag
|
||||
--flag_a second flag
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("test").version("1.2").args(&[
|
||||
Arg::new("help")
|
||||
.long("help")
|
||||
.short('h')
|
||||
.help("Print help message"),
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("flag_a").long("flag_a").help("second flag"),
|
||||
]);
|
||||
|
||||
utils::assert_output(cmd, "test --help", PREFER_USER_HELP_DERIVE_ORDER, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prefer_user_help_in_subcommand_with_derive_order() {
|
||||
let cmd = Command::new("test")
|
||||
.global_setting(AppSettings::DeriveDisplayOrder)
|
||||
.subcommand(
|
||||
Command::new("sub").version("1.2").args(&[
|
||||
Arg::new("help")
|
||||
.long("help")
|
||||
.short('h')
|
||||
.help("Print help message"),
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("flag_a").long("flag_a").help("second flag"),
|
||||
]),
|
||||
);
|
||||
static PREFER_USER_HELP_SUBCMD_DERIVE_ORDER: &str = "test-sub 1.2
|
||||
|
||||
USAGE:
|
||||
test sub [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help message
|
||||
--flag_b first flag
|
||||
--flag_a second flag
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("test").subcommand(
|
||||
Command::new("sub").version("1.2").args(&[
|
||||
Arg::new("help")
|
||||
.long("help")
|
||||
.short('h')
|
||||
.help("Print help message"),
|
||||
Arg::new("flag_b").long("flag_b").help("first flag"),
|
||||
Arg::new("flag_a").long("flag_a").help("second flag"),
|
||||
]),
|
||||
);
|
||||
|
||||
utils::assert_output(
|
||||
cmd,
|
||||
|
|
|
@ -499,9 +499,9 @@ USAGE:
|
|||
pacman {query|--query|-Q} [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
-i, --info <info>... view package information
|
||||
-s, --search <search>... search locally installed packages for matching strings
|
||||
-i, --info <info>... view package information
|
||||
-h, --help Print help information
|
||||
";
|
||||
|
||||
#[test]
|
||||
|
@ -548,9 +548,9 @@ USAGE:
|
|||
pacman {query|--query} [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
-i, --info <info>... view package information
|
||||
-s, --search <search>... search locally installed packages for matching strings
|
||||
-i, --info <info>... view package information
|
||||
-h, --help Print help information
|
||||
";
|
||||
|
||||
#[test]
|
||||
|
@ -601,9 +601,9 @@ USAGE:
|
|||
pacman {query|-Q} [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
-i, --info <info>... view package information
|
||||
-s, --search <search>... search locally installed packages for matching strings
|
||||
-i, --info <info>... view package information
|
||||
-h, --help Print help information
|
||||
";
|
||||
|
||||
#[test]
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,8 +11,8 @@ USAGE:
|
|||
|
||||
OPTIONS:
|
||||
-F, --flag2 some other flag
|
||||
-h, --help Print help information
|
||||
--option <opt> some option
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
|
@ -39,32 +39,11 @@ USAGE:
|
|||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
-v, --visible This text should be visible
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
static HIDDEN_SHORT_ARGS_LONG_HELP: &str = "test 2.31.2
|
||||
Steve P.
|
||||
hides short args
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-c, --config
|
||||
Some help text describing the --config arg
|
||||
|
||||
-h, --help
|
||||
Print help information
|
||||
|
||||
-v, --visible
|
||||
This text should be visible
|
||||
|
||||
-V, --version
|
||||
Print version information
|
||||
";
|
||||
|
||||
/// Ensure hide with short option
|
||||
#[test]
|
||||
fn hide_short_args() {
|
||||
|
@ -90,6 +69,27 @@ fn hide_short_args() {
|
|||
/// Ensure visible with opposite option
|
||||
#[test]
|
||||
fn hide_short_args_long_help() {
|
||||
static HIDDEN_SHORT_ARGS_LONG_HELP: &str = "test 2.31.2
|
||||
Steve P.
|
||||
hides short args
|
||||
|
||||
USAGE:
|
||||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-c, --config
|
||||
Some help text describing the --config arg
|
||||
|
||||
-v, --visible
|
||||
This text should be visible
|
||||
|
||||
-h, --help
|
||||
Print help information
|
||||
|
||||
-V, --version
|
||||
Print version information
|
||||
";
|
||||
|
||||
let cmd = Command::new("test")
|
||||
.about("hides short args")
|
||||
.author("Steve P.")
|
||||
|
@ -117,12 +117,12 @@ USAGE:
|
|||
test [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help
|
||||
Print help information
|
||||
|
||||
-v, --visible
|
||||
This text should be visible
|
||||
|
||||
-h, --help
|
||||
Print help information
|
||||
|
||||
-V, --version
|
||||
Print version information
|
||||
";
|
||||
|
@ -157,8 +157,8 @@ USAGE:
|
|||
|
||||
OPTIONS:
|
||||
-c, --config Some help text describing the --config arg
|
||||
-h, --help Print help information
|
||||
-v, --visible This text should be visible
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use clap::{AppSettings, Args, CommandFactory, Parser, Subcommand};
|
||||
use clap::{Args, CommandFactory, Parser, Subcommand};
|
||||
|
||||
#[test]
|
||||
fn arg_help_heading_applied() {
|
||||
|
@ -247,7 +247,6 @@ OPTIONS:
|
|||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(name = "test", version = "1.2")]
|
||||
#[clap(setting = AppSettings::DeriveDisplayOrder)]
|
||||
struct Args {
|
||||
#[clap(flatten)]
|
||||
a: A,
|
||||
|
@ -303,7 +302,6 @@ OPTIONS:
|
|||
";
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(setting = AppSettings::DeriveDisplayOrder)]
|
||||
#[clap(name = "test", version = "1.2")]
|
||||
struct Args {
|
||||
#[clap(flatten)]
|
||||
|
@ -361,7 +359,6 @@ OPTIONS:
|
|||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(name = "test", version = "1.2")]
|
||||
#[clap(setting = AppSettings::DeriveDisplayOrder)]
|
||||
#[clap(next_display_order = None)]
|
||||
struct Args {
|
||||
#[clap(flatten)]
|
||||
|
|
|
@ -9,9 +9,9 @@ USAGE:
|
|||
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
|
||||
|
||||
OPTIONS:
|
||||
--verbose log
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
--verbose log
|
||||
|
||||
SUBCOMMANDS:
|
||||
more
|
||||
|
|
|
@ -8,9 +8,9 @@ USAGE:
|
|||
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
|
||||
|
||||
OPTIONS:
|
||||
--verbose log
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
--verbose log
|
||||
|
||||
SUBCOMMANDS:
|
||||
more
|
||||
|
|
|
@ -8,15 +8,15 @@ USAGE:
|
|||
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
|
||||
|
||||
OPTIONS:
|
||||
--verbose
|
||||
more log
|
||||
|
||||
-h, --help
|
||||
Print help information
|
||||
|
||||
-V, --version
|
||||
Print version information
|
||||
|
||||
--verbose
|
||||
more log
|
||||
|
||||
SUBCOMMANDS:
|
||||
more
|
||||
|
||||
|
|
|
@ -8,15 +8,15 @@ USAGE:
|
|||
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
|
||||
|
||||
OPTIONS:
|
||||
--verbose
|
||||
more log
|
||||
|
||||
-h, --help
|
||||
Print help information
|
||||
|
||||
-V, --version
|
||||
Print version information
|
||||
|
||||
--verbose
|
||||
more log
|
||||
|
||||
SUBCOMMANDS:
|
||||
more
|
||||
|
||||
|
|
Loading…
Reference in a new issue