Commit graph

2872 commits

Author SHA1 Message Date
Ed Page
c4dd6aeb42 docs: Update example help 2022-08-30 19:57:26 -05:00
Ed Page
44d3614add revert: Add some deprecated placeholders 2022-08-30 16:47:39 -05:00
Ed Page
02d27b5ce3 fix(usage): Make dont_collapse_args_in_usage the default
The setting was added to resolve #769.  The reason it was optional is out
of concern for applications with a lot of positional arguments.  I think
those cases are rare enough that we should just push people to override
the usage.  Positional arguments are generally important enough, even if
optional, to show.

As a side effect, this fixed some bugs with
`dont_collapse_args_in_usage` where it would repeat an argument in a
smart usage.

As a side effect, smart usage now shows `--` when it should
2022-08-30 16:12:49 -05:00
Ed Page
c22b78ba61 fix(usage): Don't put in [--] for multiple values
This was added in #165 but the relative value of this doesn't seem worth
the complexity at the moment.
2022-08-30 16:01:22 -05:00
Ed Page
a00cbab1dc fix(usage): Don't list -- as optional for last
`last` must always follow a `--`, so it isn't optional.
2022-08-30 15:41:35 -05:00
Ed Page
d791a93ec7 refacor(usage): Remove use of sort 2022-08-30 11:27:14 -05:00
Ed Page
1dde9268d5 fix(usage): Don't include irrelevant parent args
This was identified in https://github.com/clap-rs/clap/discussions/4134
2022-08-30 13:43:31 -05:00
Ed Page
8da1f085dd fix(parser): Require earlier, not-present positionals 2022-08-30 09:31:46 -05:00
Ed Page
2388ace47b refactor(parser): Hoist check into iteration 2022-08-30 08:47:03 -05:00
Ed Page
619b1fb187 perF(usage): Defer de-duplicating to later
This should drop code size
2022-08-30 07:15:50 -05:00
Ed Page
66957f8398 refactor(usage): Make last check clearer 2022-08-29 21:26:39 -05:00
Ed Page
09031fb4ab refactor(usage): Consolidate required bookkeeping 2022-08-29 21:26:35 -05:00
Ed Page
85569514db refactor(usage): Make duplicate check more resilient 2022-08-29 21:26:32 -05:00
Ed Page
3b17f7fdc9 refactor(usage): Pull out duplicate check 2022-08-29 21:26:28 -05:00
Ed Page
ecb632f487 refactor(usage): Split out group processing 2022-08-29 21:26:24 -05:00
Ed Page
26ea3e32d0 refactor(parser): Consolidate the loops 2022-08-29 19:42:21 -05:00
Ed Page
0c9b9d7ec8 fix(parser): Show all required errors at once
This also has the side effect of always using the "smart usage" which is
why the tests changed.
2022-08-29 19:40:35 -05:00
Ed Page
14d910dee1 refactor(parser): Prefer explicit for loops 2022-08-29 17:04:17 -05:00
Ed Page
3c466c63f7 refactor(parser): Flatten required_unless logic 2022-08-29 17:02:05 -05:00
Ed Page
dacc8ff43a refactor(parser): Consolidate presence check 2022-08-29 16:59:58 -05:00
Ed Page
76dd3a18e2 fix(help): Ensure consistency in usage 2022-08-29 15:50:39 -05:00
Ed Page
02db3043e2 fix(help): Consistently use [] for positionals
In the usaeg we use `[]` but in the arg list we use `<>`.
2022-08-29 15:34:30 -05:00
Ed Page
5ef803f01a refactor(help): Move close to use 2022-08-29 15:18:46 -05:00
Ed Page
91332267cf refactor(help): Positive logic can clarify intent 2022-08-29 14:29:32 -05:00
Ed Page
87e2d0c2e0 refactor(help): Clarify intent of fn 2022-08-29 14:07:10 -05:00
Ed Page
2b4541fab2 refactor(help): Clean up code 2022-08-29 14:04:27 -05:00
Ed Page
36460aed08 fix: Deprecate _os variants
PR #4096 made them redundant
2022-08-29 12:42:30 -05:00
Ed Page
4eeee9b110 fix(help): Command::print_help should respect disable_colored_help 2022-08-29 10:47:08 -05:00
Andrew Shu
eec047a6f6 fix(help): Do not propagate global args to help
This prevents global args from showing in help completions,
since help completions should only suggest subcommands.
Adds tests to ensure the args still show in the generated
help messages of subcommands.
2022-08-26 17:48:58 -07:00
Ed Page
294868f5d8
Merge pull request #4115 from talklittle/completion-help-parser-flag
feat(complete): Add completion for help subcommands
2022-08-26 15:28:21 -05:00
Andrew Shu
0d0be51606 fix(complete): Fix help completion issues
* Copy hide flag

* Revert global args special handling. Another commit will
address the issue of whether global args should be included in
help subtrees.
2022-08-26 12:57:12 -07:00
Ed Page
e02648e66b fix(help): Don't dim placeholders
This came from feedback: https://rust-lang.zulipchat.com/#narrow/stream/220302-wg-cli/topic/Help.20changes.20in.20clap.20v4
2022-08-26 11:46:44 -05:00
Ed Page
83d6add9aa fix(help): Shift focus to subcommands, when present
In surveying various tools and CLI parsers, I noticed they list the
subcommands first.  This puts an emphasis on them which makes sense
because that is most likely what an end user is supposed to pass in
next.

Listing them last aligns with the usage order but it probably doesn't
outweigh the value of getting a user moving forward.
2022-08-26 10:59:40 -05:00
Ed Page
9b23a09f7a fix(help): Don't rely on ALL CAPS for headers
I see them fulfilling two roles
- A form of bolding
- As a callback to their placeholder in usage

However, it is a bit of an unpolished look and no other CLI seems to do
it.  This looks a bit more proefessional.  We have colored help for
formatting and I think the sections relation to usage will be clear
enough.
2022-08-26 10:21:18 -05:00
Ed Page
8315ba3dd6 fix(error): Don't underline indentation 2022-08-26 07:15:57 -05:00
Ed Page
6079a871a0 fix(help): Use a more neutral palette
Fixes #2963
2022-08-25 19:23:52 -05:00
Andrew Shu
729406661c refactor(complete): Clean up help completion
* Manual subtree copy to ensure correct behavior and settings
* Always set ExpandHelpSubcommandTrees in Command::build
* Remove redundant logic
2022-08-25 15:43:27 -07:00
Ed Page
d6d838ebe2 feat: Allow stylized usage 2022-08-25 17:07:06 -05:00
Andrew Shu
fdcee9313f feat(complete): Add completion for help subcommands
Adds parser flags to toggle whether to run the
expensive clone logic for completions case.

Help completion will only suggest subcommands, not args.

clap_complete generator sets the flag.
2022-08-25 13:58:08 -07:00
Ed Page
8382675985 style: Fix a typo 2022-08-25 13:45:36 -05:00
Ed Page
81f29d29ad refactor(help): Top-down sort functions 2022-08-25 13:39:21 -05:00
Ed Page
0c2f20d660 refactor(help): Drop the parser macro 2022-08-25 13:32:08 -05:00
Ed Page
207bb00453 refactor(help): Simplify several parts 2022-08-25 13:26:21 -05:00
Ed Page
d652f0348d refactor(help): Reduce a fn's visibility 2022-08-25 13:15:20 -05:00
Ed Page
df7616b820 fix(help): Match v3 usage for optional positionals 2022-08-25 13:13:09 -05:00
Ed Page
0e0c5eb218 refactor(help): Consolidate value printing 2022-08-25 13:07:32 -05:00
Ed Page
e00abc6905 refactor(help): Consolidate arg suffix rendering
This ended up favoring the help implementation
2022-08-25 13:01:27 -05:00
Ed Page
8607695ed9 refactor(help): Simplify the code
While this doesn't reduce size, it cleans things up to make it easier
2022-08-25 12:47:52 -05:00
Ed Page
64753bbc7d refactor(help): Make spec value implementations more flexible 2022-08-25 11:54:34 -05:00
Ed Page
06c40b636e refactor(help): Clarify arg separator 2022-08-25 11:33:21 -05:00