Commit graph

21 commits

Author SHA1 Message Date
Ed Page
61c9e6265b fix(help)!: Merge OPTIONS / FLAGS default groups
For those that want the original behavior, you can usxe
`arg.help_heading(Some("FLAGS"))` on your flags.  Limitations:
- This will not give you a special sort order
- This will not get a `[FLAGS]` added to usage

For templates, we removed `{unified}` and `{flags}`.  To help people
catch these, a debug_assert was added.

I'm unsure but I think there might be a change in behavior in calcuating
when to show `[OPTION]` in usage.  The old code only looked at
`required` while flags looked only at arg groups.  We now look at both.

Ideally we'd add these in `_build` and remove special casing for
no-groups except in the sort order of groups.  I feel like thats best
left for later.

This also reduced the scope of `App`s public API.
`get_*_with_no_heading` seemed a bit specialized to be in the public
API.  #2853 looks at splitting it out into its own PR.

BREAKING CHANGE: Multiple
- `UnifiedHelpMessage` removed
- `{flags}` and `{unified}` are removed and will assert when present.
- `get_*_with_no_heading` removed

Fixes #2807
2021-10-13 11:42:10 -05:00
Kevin K
14c8850019
tests: fixes test to new default behavior
This commit corrects tests to not expect the `-V,--version` flag when no
version information has been provided.
2021-10-09 11:12:50 -04:00
Morley, Jonathan
1d3a292d6b assert on leading and trailing whitespace 2021-09-24 12:38:15 -04:00
patrick-gu
a4dc72ed19 Replace "Prints" with "Print" for default help and version commands 2021-07-29 20:23:25 -07:00
Pavan Kumar Sunkara
3f94d17c71 Removed Arg::multiple 2021-06-16 07:17:11 +01:00
rami3l
fbd338ce26
fix: flag_subcommands unexpected behavior after long arg (#2501)
* fix(wip): add necessary debugging prints for analysis

* fix(wip): implement the fix, take 1

* docs: add docstring for `Parser::flag_subcmd_at` and `Parser::flag_subcmd_skip`

* test: make `flag_subcommand_short_after_long_arg` test more realistic
2021-05-27 05:14:50 +05:30
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
CreepySkeleton
32414fbdff Fix and rearrange debug asserts 2020-08-12 06:12:42 +03: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
NickHackman
432be5bc30 tests: conflicts with flag sc and arg aliases
Tests to check for conflicts between flag subcommands long and short and
their aliases and args both long and short and their aliases. Tests to
handle self conflicts, where a flag subcommand short or long with have a
corresponding alias with the same value.
2020-07-11 15:00:40 -04:00
NickHackman
5118cec1b1 fix: long_flag_aliases instead of using alias
Previously long_flag alias checks were against normal aliases instead of
specifically designated long_flag aliases, this is more clear and explicit.
2020-07-10 09:27:14 -04:00
NickHackman
1127ca6e13 feat: Usage displays short, long, and normal scs
Displayed in the form of

pacman {query, --query, -Q} [OPTIONS]
2020-07-08 21:37:56 -04:00
NickHackman
ec35ab8813 feat: long flag subcommand infer
Added tests and feature to infer long flag subcommands similarly to
normal subcommands.
2020-07-08 00:11:28 -04:00
NickHackman
d785ebc14e fix: Flag Subcommands tests behind debug_asserts
Tests that check conflicts are behind the `debug_assertions` feature
2020-06-17 01:53:53 -04:00
NickHackman
32db427706 fix: duplicate short flags in Flag Subcommand test 2020-06-17 01:14:48 -04:00
NickHackman
f7c5b098b9 fix: duplicate flags in Flag Subcommand test 2020-06-17 00:56:05 -04:00
NickHackman
bf3d947f01 fix: Flag Subcommands conflicts panic
Conflicts with Flag subcommands and Args now panics when
`debug_assertions` is enabled, rather than causing bizarre behavior.
2020-06-16 23:45:21 -04:00
NickHackman
383606e099 tests: short_flag_alias methods
Tests that cover all methods for `short_flag_alias` corresponding methods
2020-06-16 01:11:53 -04:00
NickHackman
458736bee8 imp: Improved Flag Subcommand API
Instead of a `FlagSubCommand` struct the addition of two simple methods
to `App`. `App::long_flag` and `App::short_flag` that cover all the
bases of the many methods that were provided in `FlagSubCommand`. This
API is far simpler to use and more akin to the present `Arg::long` and `Arg::short`.
2020-06-15 21:52:36 -04:00
NickHackman
c89718fa57 tests: FlagSubCommand
Test all methods of `FlagSubCommand` and interactions with aliases
2020-06-13 11:32:24 -04:00