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
ldm0
886b873709 Demangle interlinking flags 2021-03-09 13:45:11 +00:00
Pavan Kumar Sunkara
6634444c3c Remove Arg::settings to be consistent with App 2021-02-12 10:42:38 +00:00
Pavan Kumar Sunkara
7bc282dd4e Rename with_name to new for Arg & ArgGroup 2020-05-14 22:50:56 +02:00
creativcoder
35fdb45adb Update bench tests with about and add inline to about methods 2020-04-27 20:00:36 +05:30
CreepySkeleton
9d1cf49ca8 Move to criterion 2020-02-21 18:21:31 +03:00
Pavan Kumar Sunkara
5b3a0dff9c Remove extern & macro_use where possible 2020-02-07 07:34:01 +01:00
Kevin K
f0d6278685
refactor: fixes benches to the new fewer required lifetime parameter 2019-04-05 20:21:27 -04:00
Kevin K
20c72525d2 style: cargo fmt run 2018-11-14 12:05:06 -05:00
Kevin K
f6ce7d5cc2
refactor: makes benches compile on v3 2018-11-13 22:16:02 -05:00
Kevin K
0de9e07412
Merge branch 'v3-master' into map 2018-11-13 22:07:16 -05:00
Kevin K
03333800fe refactor: remove code going to other crates and deprecations 2018-10-19 23:31:06 -04:00
Alena Yuryeva
1216cddb63 Fixed help benchmark 2018-09-01 20:42:31 +03:00
Kevin K
94872e00a5
refactor(Arg): changes Arg::short to accept a char instead of &str
Closes #1303
2018-07-23 15:10:12 -04:00
Kevin K
41572e4d2d
benches: partially updates the benches to new arg.setting calls 2018-02-03 15:06:58 -05:00
Kevin K
4c54c2a696
tests: silence some warnings 2018-01-25 23:03:13 -05:00
Kevin K
1ab10275e4
style: rustfmt run 2018-01-25 12:21:17 -05:00
Kevin K
85a636d539
tests(Benches): adds real world benchmarks 2017-02-28 08:30:13 -05:00
Hernan Grecco
627ae38dc0 refactor(HELP): Removed code for old help system and tests that helped with the transitions 2016-04-13 07:21:21 -03:00
Hernan Grecco
81e121edd6 feat(HELP): Add a Templated Help system.
The strategy is to copy the template from the the reader to wrapped stream
until a tag is found. Depending on its value, the appropriate content is copied
to the wrapped stream.
The copy from template is then resumed, repeating this sequence until reading
the complete template.

Tags arg given inside curly brackets:
Valid tags are:
    * `{bin}`         - Binary name.
    * `{version}`     - Version number.
    * `{author}`      - Author information.
    * `{usage}`       - Automatically generated or given usage string.
    * `{all-args}`    - Help for all arguments (options, flags, positionals arguments,
                        and subcommands) including titles.
    * `{unified}`     - Unified help for options and flags.
    * `{flags}`       - Help for flags.
    * `{options}`     - Help for options.
    * `{positionals}` - Help for positionals arguments.
    * `{subcommands}` - Help for subcommands.
    * `{after-help}`  - Help for flags.
2016-04-13 07:06:23 -03:00
Hernan Grecco
04b5b074d1 refactor(HELP): A new Help Engine
The largest organizational change is that methods used to generate the help are
implemented by the Help object and not the App, FlagBuilder, Parser, etc.

The new code is based heavily on the old one with a few minor modifications
aimed to reduce code duplication and coupling between the Help and the rest
of the code.

The new code turn things around: instead of having a HelpWriter that holds an
AnyArg object and a method that is called with a writer as argument,
there is a Help Object that holds a writer and a method that is called with a
writer as an argument.

There are still things to do such as moving `create_usage` outside the Parser.

The peformance has been affected, probably by the use of Trait Objects. This
was done as a way to reduce code duplication (i.e. in the unified help code).
This performance hit should not affect the usability as generating and printing
the help is dominated by user interaction and IO.

The old code to generate the help is still functional and is the active one.
The new code has been tested against the old one by generating help strings
for most of the examples in the repo.
2016-04-13 07:06:23 -03:00