Commit graph

858 commits

Author SHA1 Message Date
Kevin K
fedb46b5b1 fix: fixes a bug where flags were parsed as flags AND positional values when specific combinations of settings were used
This commit fixes a bug where using `AppSettings::AllowHyphenValues`
would cause flags with longs be *also* parsed as positional values.

Closes #946
2017-05-07 10:46:03 -04:00
Kevin K
52d110df81 docs(AllowHyphenValues): updates the docs to remove old limitations that no longer apply 2017-05-07 10:46:03 -04:00
Nuew
d5ef895541
api(Arg): add default_value_os
Also add related tests, and reframe `default_value` in terms of
`defualt_value_os`.
2017-04-24 15:49:59 -04:00
Pyry Kontio
0a4384e350 api(arg_matches.rs): Added a Default implementation for Values and OsValues iterators. 2017-04-23 23:49:20 +09:00
Kevin K
85b0e1cc4b
imp(PowerShell Completions): massively dedups subcommand names in the generate script to make smaller scripts that are still functionally equiv 2017-04-18 23:17:05 -04:00
Kevin K
a8bce55837
fix(PowerShell Completions): fixes a bug where powershells completions cant be used if no subcommands are defined
Closes #931
2017-04-18 23:01:20 -04:00
Michael Daffin
71dabba3ea docs: Fix a typo the minimum rust version required 2017-04-07 10:02:00 +01:00
Kevin K
6aa4ba8114 fix: fixes a missing newline character in the autogenerated help and version messages in some instances 2017-04-05 10:59:55 -04:00
Kevin K
f7a8877978 feat(clap_app!): adds support for arg names with hyphens similar to longs with hyphens
One can now use `("config-file")` style arg names

Closes #869
2017-04-05 00:57:47 -04:00
Kevin K
bc08ef3e18 docs(clap_app!): documents the --("some-arg") method for using args with hyphens inside them
Closes #919
2017-04-05 00:47:19 -04:00
Kevin K
59272b06cc feat: allows distinguishing between short and long version messages (-V/short or --version/long)
One can now use `App::long_version` to dsiplay a different (presumably
longer) message when `--version` is called. This commit also adds the
corresponding print/write long version methods of `App`
2017-04-05 00:42:43 -04:00
Kevin K
d82b4be5d7 api: adds new App method calls for printing and writing the long version of help messages
One can now use `App::print_long_help` or `App::write_long_help`

Note that `App::write_long_help` is **NOT** affected by kbknapp/clap-rs#808 in the manner
that `App::write_help` help is and thus should be preferred if at all possible.
2017-04-05 00:42:43 -04:00
Kevin K
6b371891a1 feat: allows distinguishing between short and long help with subcommands in the same manner as args
One can use `App::about` for `-h` short help messsages or
`App::long_about` for `--help` long help messages.
2017-04-05 00:42:43 -04:00
Kevin K
ef1b24c3a0 feat: allows specifying a short help vs a long help (i.e. varying levels of detail depending on if -h or --help was used)
One can now use `Arg::long_help` which will be displayed when the user
runs `--help`. This is typically longer form content and will be
displayed using the NextLineHelp methodology.

If one specifies the standard `Arg::help` it will be displayed when the
user runs `-h` (by default, unless the help short has been overridden).
The help text will be displayed in the typical clap fashion.

The help format requested (-h/short or --help/long) will be the
*default* displayed. Meaning, if one runs `--help` (long) but only an
`Arg::help` has been provided, the message from `Arg::help` will be
used. Likewise, if one requests `-h` (short) but only
`Arg::long_help` was provided, `Arg::long_help` will be displayed appropriately
wrapped and aligned.

Completion script generation *only* uses `Arg::help` in order to be
concise.

cc @BurntSushi thanks for the idea!
2017-04-05 00:42:43 -04:00
Kevin K
8b2ceb8368 fix: fixes a bug that wasn't allowing help and version to be properly overridden
One should be able to override the auto generated help and version flags
by simply providing an arg with a long of `help` or `version`
respectively. This bug was preventing that from happening.

However, now that it's fixed if one was relying on adding an arg with a
long of `help` or `version` and using `get_matches_safe` to produce the
`ErrorKind::HelpDisplayed` or `ErrorKind::VersionDisplayed` errors they
**WILL NOT** happen anymore.

This is because the bug was causing those "errors" to occur (i.e. the
help or version message to be displayed). The "fix" to get that
functionality back is to either:

 * Remove the arg with the long of `help` or `version`
 * Use `ArgMatches::is_present` instead of `App::get_matches_safe` to check for the presence of your custom help or version flag

Option 1 is the easiest provided one wasn't using said arg to *also*
override other aspects of the flags as well (short, help message, etc.)

Even though this may break some code, as per the compatibility policy
listed in the readme; code that breaks due to relying on a bug does
*not* constitute a major version bump. I will however be bumping the
minor version instead of just the patch version. I will also be
searching for, contacting, and attempting to submit PRs to any affected
projects prior to releasing the next version to crates.io

Closes #922
2017-04-04 19:59:03 -04:00
Kevin K
f93cadd74b tests: fixes a missing import for a doctest and uses conditional doc-testing 2017-03-30 15:19:17 -04:00
Kevin K
0e4fd96d74 fix(Custom Usage Strings): fixes the usage string regression when using help templates 2017-03-30 13:30:23 -04:00
Kevin K
a442211b39 fix(usage): fixes a big regression with custom usage strings 2017-03-24 11:27:23 -04:00
Richard Janis Goldschmidt
d49e8292b0
api(App::name): adds the ability to change the name of the App instance after creation
Closes #908
2017-03-22 20:27:20 -04:00
CrazyMerlyn
89e6ea861e
api(Arg::hide_default_value): adds ability to hide the default value of an argument from the help string
Adds a new method, `Arg::hide_default_value`, which allows for
specifying whether the default value of the argument should be hidden
from the help string.

Closes #902
2017-03-22 20:26:31 -04:00
CrazyMerlyn
6bf5bf5bee
fix(yaml): adds support for loading author info from yaml
fix(yaml): adds support for loading author info from yaml
2017-03-22 20:23:55 -04:00
Pierre-Eric Pelloux-Prayer
f8f68cf825 imp: add fish subcommand help support 2017-03-17 17:46:24 +01:00
Kevin K
c8eb0384d3
imp: options that use require_equals(true) now display the equals sign in help messages, usage strings, and errors"
Closes #903
2017-03-16 21:43:36 -04:00
Armin Ronacher
e06689fc26 Propagate terminal widths to subcommands 2017-03-16 14:19:10 +01:00
Kevin K
74b751ff2e
fix(ArgRequiredElseHelp): fixes the precedence of this error to prioritize over other error messages
Closes #895
2017-03-12 12:52:09 -04:00
Kevin K
9a3bc98e9b
fix(Positionals): fixes some regression bugs resulting from old asserts in debug mode.
Closes #896
2017-03-12 12:43:10 -04:00
Kevin K
96884aa1b2
refactor: implements PartialEq for some of the base structs 2017-03-11 12:38:24 -05:00
Kevin K
f9668297a4
api(Arg::last): adds the ability to mark a positional argument as 'last' which means it should be used with -- syntax and can be accessed early
Marking a positional argument `.last(true)` will allow accessing this argument earlier if the `--` syntax is used (i.e. skipping other positional args)
and also change the usage string to one of the following:

* `$ prog [arg1] [-- <last_arg>]`
* `$ prog [arg1] -- <last_arg>` (if the arg marked `.last(true)` is also marked `.required(true)`)

Closes #888
2017-03-11 12:14:54 -05:00
Kevin K
989862d2cb
chore: fixes small rebase regression 2017-03-10 15:27:24 -05:00
Kevin K
9d4535e1c3
chore: clippy run 2017-03-10 08:24:30 -05:00
Kevin K
075036c28d
fix: fixes a regression 1.11.0 feature 2017-03-10 08:24:30 -05:00
Kevin K
1e4cce0291
tests: corrects the debug messages from the usage module 2017-03-10 08:24:30 -05:00
Kevin K
d2b4c2c61b
fix: fixes false positive clean parse when the suggestions feature is disabled and InferSubcommands is enabled 2017-03-10 08:24:30 -05:00
Kevin K
b841f3743f
fix: fixes a failing build with no-default-features 2017-03-10 08:24:30 -05:00
Kevin K
d484da0d28
fix: fixes a misspelled import for Windows 2017-03-10 08:24:29 -05:00
Kevin K
33eb5a6db0
tests: fixes failing dual usage string help test 2017-03-10 08:24:29 -05:00
Kevin K
622b609c57
refactor: moves usage string generation code into it's own module 2017-03-10 08:24:29 -05:00
Kevin K
44ed8b663c
refactor: moves validation code into it's own module 2017-03-10 08:24:29 -05:00
Kevin K
c8ab24bafa
imp: when AppSettings::SubcommandsNegateReqs and ArgsNegateSubcommands are used, a new more accurate double line usage string is shown
Closes #871
2017-03-10 08:24:29 -05:00
Kevin K
d63d404e5e
fix: doesn't print the argument sections in the help message if all args in that section are hidden 2017-03-10 08:24:28 -05:00
Kevin K
539ad6073f
fix: doesn't include the various [ARGS] [FLAGS] or [OPTIONS] if the only ones available are hidden
Closes #882
2017-03-10 08:24:28 -05:00
Kevin K
97e8db23b3
fix: now correctly shows subcommand as required in the usage string when AppSettings::SubcommandRequiredElseHelp is used
Close #883
2017-03-10 08:24:28 -05:00
Kevin K
91d8280322
chore: rustfmt run 2017-03-10 08:24:28 -05:00
Kevin K
6f638a53c1
perf: doesn't run arg_post_processing on multiple values anymore 2017-03-10 08:24:28 -05:00
Kevin K
150756b989
setting(InferSubcommands): adds a setting to allow one to infer shortened subcommands or aliases (i.e. for subcommmand "test", "t", "te", or "tes" would be allowed assuming no other ambiguities)
Closes #863
2017-03-10 08:22:31 -05:00
Joost Yervante Damad
8adf353e0b
fix(help): don't show ARGS when there are only hidden positional args
Also no need to check for Hidden inside for that already is filtered
on !Hidden.

Closes #882
2017-03-10 08:22:31 -05:00
Kevin K
24e3839220
perf: changes internal use of VecMap to Vec for matched values of Args
This makes a very big difference for CLIs that parse a large number of
values (think ripgrep over a large directory).

This commit improved the ripgrep parsing of ~2,000 values, simulating
giving ripgrep a bunch of files. Parsing when from ~1,200,000 ns to
~400,000 ns! This was conducted a i7-5600U 2.6GHz
2017-03-10 08:22:31 -05:00
Caleb Jones
c5dac3fa43 Support loading help_message and version_message from the YAML 2017-03-10 01:54:50 -05:00
Caleb Jones
389c413b70 Allow customizing the --version and --help messages 2017-03-10 01:01:56 -05:00
Anthony Ramine
f4939ad560 Remove direct dependency on libc
It's not actually used anymore anywhere.
2017-03-05 19:44:16 +01:00