Commit graph

1961 commits

Author SHA1 Message Date
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
Homu
5b669ec520 Auto merge of #923 - kbknapp:issues-869,900,919,922, r=kbknapp
Issues 869,900,919,922

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/923)
<!-- Reviewable:end -->
2017-04-05 21:57:49 +09:00
Kevin K
cdae4fdf89 chore: increase version 2017-04-05 01:09:16 -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
c83a559df1 tests(clap_app!): adds tests for ("config-file") style positonal args 2017-04-05 00:57:40 -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
b48a5bb930 chore: bump minor version due to bug fix that may break code that was relying on said bug 2017-04-04 20:11:33 -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
92cc30577d tests: adds tests to verify help and version can be properly overridden 2017-04-04 19:56:34 -04:00
Homu
080a9d8bfe Auto merge of #921 - kbknapp:template-fix, r=kbknapp
Template fix

Fixes BurntSushi/ripgrep#426 and BurntSushi/ripgrep#418

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/921)
<!-- Reviewable:end -->
2017-03-31 05:00:54 +09: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
8bcc4d632c chore: increase version 2017-03-30 13:35:36 -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
f922b05178 chore: increase version 2017-03-24 11:27:23 -04:00
Kevin K
1a97f4fb95 tests: adds regression tests for custom usage strings 2017-03-24 11:27:23 -04:00
Kevin K
a442211b39 fix(usage): fixes a big regression with custom usage strings 2017-03-24 11:27:23 -04:00
Kevin K
cc1985b6d8
chore: increase version 2017-03-22 20:29:40 -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
6b491c1161
tests(Help): adds tests for per argument hiding of default value 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
Kevin K
0b4177f151
chore: increase version 2017-03-22 20:23:55 -04:00
Kevin K
fa3876ce36
chore(justfile): sorts the contributors by commits 2017-03-22 20:23:55 -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
Homu
0d2a3f6ddb Auto merge of #907 - kbknapp:v2.21.2, r=kbknapp
chore: increase version

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/907)
<!-- Reviewable:end -->
2017-03-19 08:58:11 +09:00
Kevin K
8034fe70f2
chore: increase version 2017-03-18 17:06:43 -04:00
Homu
8edb1f9808 Auto merge of #905 - peppsac:fish_subcommand_help, r=kbknapp
imp: add fish subcommand help support

Adds the `-d help_string` parameter to fish completion is present.

Example output:
```
complete -c mm3d -n "__fish_using_command mm3d" -f -a "Ann" -d "matches points [...]"
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/905)
<!-- Reviewable:end -->
2017-03-18 03:15:57 +09:00
Pierre-Eric Pelloux-Prayer
f8f68cf825 imp: add fish subcommand help support 2017-03-17 17:46:24 +01:00
Homu
b08d7d13bf Auto merge of #906 - kbknapp:issue-903, r=kbknapp
Issue 903
2017-03-17 11:43:20 +09:00
Kevin K
684aa99ee0
chore: increase version 2017-03-16 21:50:26 -04:00
Kevin K
c84416f48d
tests: adds tests for reqire_equals(true) errors and help 2017-03-16 21:45:45 -04: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
Homu
16764bfa27 Auto merge of #904 - mitsuhiko:feature/term-meta-propagation, r=kbknapp
Propagate terminal widths to subcommands

This fixes #901
2017-03-16 23:15:59 +09:00
Armin Ronacher
e06689fc26 Propagate terminal widths to subcommands 2017-03-16 14:19:10 +01:00
Homu
1b2e7ad4e4 Auto merge of #898 - kbknapp:issues-896,895, r=kbknapp
Issues 896,895
2017-03-13 03:17:34 +09:00
Kevin K
e7c2eafb26
chore: increase version 2017-03-12 12:56:23 -04:00
Kevin K
ef037eaf22
tests: adds tests to check precedence of ArgRequiredElseHelp 2017-03-12 12:53:40 -04: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
b049cecccc
tests: adds tests for passing assertions with new Arg::last setting 2017-03-12 12:45:59 -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
Homu
814b12644e Auto merge of #893 - kbknapp:issues-863,perf-imp2,883,882,871, r=kbknapp
Issues 863,perf imp2,883,882,871
2017-03-12 03:31:19 +09:00
Kevin K
96884aa1b2
refactor: implements PartialEq for some of the base structs 2017-03-11 12:38:24 -05:00
Kevin K
c53e273c7c
chore: updates the changelog and readme with .last(true) details 2017-03-11 12:14:54 -05:00
Kevin K
10f1ebce7f
chore: ups the codegen units for test builds 2017-03-11 12:14:54 -05:00
Kevin K
3a10353f4b
tests: adds tests for .last(true) args 2017-03-11 12:14:54 -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