Commit graph

141 commits

Author SHA1 Message Date
Morley, Jonathan
1d3a292d6b assert on leading and trailing whitespace 2021-09-24 12:38:15 -04:00
Roland Fredenhagen
5580e8c465
ArgValue builder (#2758)
* feat(arg_value): ArgValue can be used for possible_values

Through the ArgValue it is possible:

* `hide` possible_values from showing in completion, help and validation
* add `about` to possible_values in completion

* Resolved a few change-requests by epage

* make clippy happy

* add ArgValue::get_visible_value

* remove verbose destructering

* rename ArgValue::get_hidden to ArgValue::is_hidden

* add test for help output of hidden ArgValues

* Documentation for ArgValue

There is an issue that required to implement From<&ArgValue> for
ArgValue. We should probably find a solution without that.

* fix requested changes by epage

* fix formatting

* add deref in possible_values call to remove From<&&str>

* make clippy happy

* use copied() instad of map(|v|*v)

* Finishing up for merge, hopefully

* changes requested by pksunkara
2021-09-19 10:29:09 +00:00
patrick-gu
044f9c5669
Don't suggest help or --help when not applicable (#2749)
* Don't suggest `help` or `--help` when not applicable

* Apply suggestions from code review

Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>

* Update test usage to match intended

Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-09-04 20:10:24 +00:00
Donough Liu
0394ae6102
Fix handling of number_of_values when displaying arg (#2701)
* Remove dead logic

* Outline common logic

* Fix issue 1571
2021-08-17 09:17:18 +00:00
Pavan Kumar Sunkara
9dd75987df Remove TakesValue restriction for HideEnv* 2021-08-15 19:40:24 +01:00
Pavan Kumar Sunkara
c7985fb73e Add env feature gate 2021-08-14 01:55:05 +01:00
liudingming
a60836d96a Make value_delimiter accept char rather than String 2021-08-14 02:54:56 +08:00
Steven Engler
1bd63feffe Hide help heading when all args are hidden 2021-08-12 00:51:58 +01:00
rami3l
d7c984896d fix(style): remove unnecessary usages of 'static and ref 2021-08-02 23:05:21 +02:00
patrick-gu
88dec14775
Fix order of arguments in help message with AllowMissingPositional (#2648)
* Fix small formatting error

I accidentally introduced this in #2642

* Fix order of arguments in help message with AllowMissingPositional
2021-07-31 07:39:23 +01:00
patrick-gu
a4dc72ed19 Replace "Prints" with "Print" for default help and version commands 2021-07-29 20:23:25 -07:00
liudingming
62fa1e7454 Print value_name number_of_values times with single value_name 2021-07-21 03:38:58 +08:00
anatawa12
89d1519f69
Show summary in subcommands list (#2558)
* Show short about in SUBCOMMANDS list

* add tests

* move test

* cargo fmt
2021-06-20 16:28:50 +01:00
Pavan Kumar Sunkara
e5e20b389e Forbid multiple_occurrences for positional args 2021-06-16 08:27:04 +01:00
Pavan Kumar Sunkara
3f94d17c71 Removed Arg::multiple 2021-06-16 07:17:11 +01:00
ldm0
886b873709 Demangle interlinking flags 2021-03-09 13:45:11 +00:00
Logan SQUIREL
3c049b4e22
Fix compatibility with help2man output (see #1432)
Change default help template:
- The new template introduce new lines before and after
author/about sections.
- Add help template placeholders:
    - about-section
    - author-section
- Documentation of new placeholders in clap::App::help_template
- Update all unit tests by incorporating new lines
2021-02-27 16:20:52 +01:00
Pavan Kumar Sunkara
6634444c3c Remove Arg::settings to be consistent with App 2021-02-12 10:42:38 +00:00
Pavan Kumar Sunkara
2b5a23597a Better help message support for hidden and heading stuff 2021-02-08 05:22:27 +00:00
Pavan Kumar Sunkara
3758bba5e2 Remove help_about in favor of mut_arg 2021-02-07 17:22:56 +00:00
Pavan Kumar Sunkara
423e2dde00 Remove version_about in favor of mut_arg 2021-02-07 16:14:07 +00:00
Pavan Kumar Sunkara
1bd902370a Add tests for mut_arg on help and version 2021-02-07 15:54:24 +00:00
Pavan Kumar Sunkara
c9cb22905c Build help and version args at the beginning 2021-02-07 14:46:38 +00:00
Donough Liu
d7e2fd6294 Add regression test for issue 1794 2020-12-09 01:13:05 +08:00
Pavan Kumar Sunkara
b89163afb6 Update MSRV to 1.46 2020-11-28 11:58:28 +00:00
bors[bot]
97b4fb639f
Merge #2165
2165: Help & Version settings r=pksunkara a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-10-28 06:27:49 +00:00
Pavan Kumar Sunkara
5dd9584119 Improve the logic for help & version building & parsing 2020-10-26 12:13:03 +01:00
Donough Liu
a19bfa1c35 Consistently wrap help and subcommand messages(with refactoring) 2020-10-25 22:43:01 +01:00
Pavan Kumar Sunkara
d6e2246aab Rename setting DisableVersion => DisableVersionFlag 2020-10-24 16:03:12 +02:00
Pavan Kumar Sunkara
45f0ee8b55 Rename setting DisableHelpFlags => DisableHelpFlag 2020-10-24 16:03:12 +02:00
Jacob Mischka
b3e638ad44
Add option to hide autogenerated env section from help text 2020-10-17 16:48:35 -05:00
Donough Liu
15c77150a9 Sort options base on option's short and long representation 2020-10-11 02:08:10 +08:00
bors[bot]
91633741e9
Merge #2143
2143: api(App): Adds help_about method to App. r=pksunkara a=pretzelhammer



Co-authored-by: pretzelhammer <7769424+pretzelhammer@users.noreply.github.com>
2020-09-26 06:55:58 +00:00
pretzelhammer
523729d3fc api(App): Adds version_about method to App.
Version about text is now customizable and propagates to subcommands. Closes #1640.
2020-09-25 09:06:35 -04:00
pretzelhammer
33caf49793 api(App): Adds help_about method to App.
Help about text is now customizable and propagates to subcommands. Closes #2080.
2020-09-24 17:53:02 -04:00
Felix Van der Jeugt
74cfcb4412
Add test for escaped values in help messages 2020-09-23 10:45:14 +02:00
Danil Kondratiev
5b07c8a780
fix spaces in long help tests 2020-08-20 17:28:40 +03:00
Matt Kantor
247d823314 Do not capture args meant for libtest from integration tests.
Using `App::get_matches` from the integration tests meant that any
CLI arguments passed to libtest would also be captured by clap, often
causing the tests to fail.

For example, running `cargo test --test help -- --nocapture` would
result in several failed tests, even though `cargo test --test help`
worked fine. This was very surprising/confusing.

This commit makes the tests no longer implicitly rely on the value of
`env::args_os()`, which means developers can now provide arguments to
libtest without failures.
2020-08-18 11:50:48 -07:00
Matt Kantor
de6a5af1b2 Add a (failing) test for no args + after help. 2020-08-14 13:58:56 -07:00
Matt Kantor
f7e2fbf150 Print an empty line after multi-line argument help.
Fixes #1642.
2020-08-11 15:30:30 -07:00
Matt Kantor
bf34c04060 Add a test for --help with long argument help. 2020-08-11 15:30:30 -07:00
Craig Pastro
866f2edbed style: rename ErrorKind::{VersionDisplayed, HelpDisplayed} to present tense 2020-07-20 10:27:07 +09:00
Blaxar Waldarax
748aea39f3 feat: Added {before/after}_help_long to App struct, closed #1903 2020-07-19 13:59:53 +02:00
Marti Raudsepp
594c535ba2 Fix various typos in docs & code
Most errors detected and fixed with Topy (https://github.com/intgr/topy),
all verified by hand.
2020-07-19 03:10:28 +03:00
Artem Vorotnikov
7a6310e26d
Update multiple_custom_help_headers test to cover #1955 2020-06-01 09:04:41 +03:00
CreepySkeleton
5589276093 Rename App::set_term_width to term_width
None of the other methods that move self have the `set_` prefix
2020-05-18 12:46:14 +03:00
Pavan Kumar Sunkara
7bc282dd4e Rename with_name to new for Arg & ArgGroup 2020-05-14 22:50:56 +02:00
creativcoder
d0abb378b0 cargo fmt 2020-04-27 20:41:41 +05:30
creativcoder
92d5920748 Updated test and usage of older help APIs with about 2020-04-27 02:42:07 +05:30
CreepySkeleton
2403ae796e
Apply suggestions from code review
Co-Authored-By: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-04-24 23:06:13 +03:00