Commit graph

125 commits

Author SHA1 Message Date
Ed Page
b3847b76c4 refactor: Remove vec_map dependency
Doesn't look like this dependency is buying us anything at this point,
so removing it.
2021-09-17 15:14:49 -05:00
Pavan Kumar Sunkara
76859b16bb
Merge pull request #2773 from tangmi/fix-large-display-order
Add test for very large display_order values and a possible fix
2021-09-17 19:39:37 +01:00
Mustafa Guler
50b9e65d39 Fix bug with duplicate error messages
This addresses a bug that causes duplicate flags reported in user-facing
error messages when two flags require one-another but also are required
under other conditions. The fix involves removing duplicates in unrolled
requirements, which addresses the user-facing aspect of this bug.
2021-09-17 10:47:06 -04:00
Michael Tang
cc592ed800 Add test for very large display_order values and a possible fix.
Fixes #2772
2021-09-16 19:11:30 -07: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
c7985fb73e Add env feature gate 2021-08-14 01:55:05 +01:00
Ed Page
2eb22e2b36 fix!: value_name/value_names should not append
Instead they should behave like `default_value`/`default_values`.

In implementingt this, I didn't see any reason to be using a `VecMap`.
In fact, this helped simplify the code / make intent clearer.

With this, we are also able to simplify the derive macro work from #2633.

Fixes #2634

BREAKING CHANGE: `value_name`/`value_names` always overwrite, rather
than append.  We expect the impact to be minimal.
2021-08-13 15:37:03 -05:00
Pavan Kumar Sunkara
476dd190b7
Merge pull request #2682 from clap-rs/checker
Set TakesValue to true for positional args when building
2021-08-12 22:46:15 +01:00
Pavan Kumar Sunkara
b4a662b6c9 Set TakesValue to true for positional args when building 2021-08-12 21:27:42 +01:00
Steven Engler
1bd63feffe Hide help heading when all args are hidden 2021-08-12 00:51:58 +01:00
Abyss
faa25f9e67 Make colorizer respect ColorChoice::Always 2021-07-31 18:12:54 -04: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
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
Rémi Lauzier
c4f534228b
Fix some nightly clippy warnings 2021-06-16 23:25:13 -04:00
Ajeet D'Souza
460459c771
fix(usage): Move positional args to end of usage string (#2492)
* Move positional args to end of USAGE

* Remove -- from usage string
2021-05-21 00:29:21 +05:30
Pavan Kumar Sunkara
d9fb11eba2 Apply cargo-intraconv 2021-03-13 14:11:47 +05:30
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
Andreas Molzer
c6ea3720ab Optimize common case of space padding 2021-02-25 13:26:39 +01:00
Martin Geisler
df7a8c1282 feat: remove direct unicode-width dependency
This removes the direct dependency on unicode-width and delegates the
complexity of computing the displayed width of text to the Textwrap
crate.

The `display_width` function handles characters like “æøå” (Danish),
“äöü” (German), and “😂😍” (emojis) – even if the unicode-width
Cargo feature is disabled.

This is an improvement of the former `str_width` function which would
over-estimate the width of emojis and non-ASCII characters (since they
are several bytes wide).
2021-02-20 20:56:15 +01:00
ldm0
ddb53af5dc Change some u64 to usize 2021-02-13 15:25:40 +00:00
Pavan Kumar Sunkara
2b5a23597a Better help message support for hidden and heading stuff 2021-02-08 05:22:27 +00:00
Donough Liu
8f4c26fc58 Minor redundant logic cleanup
Fix clippy

dot fix
2021-01-30 17:24:09 +00:00
Donough Liu
0df169bbdc Fix incorrect error message.
Comment out regressed logic

Fix clippy
2021-01-23 14:51:40 +00:00
Donough Liu
c6da968ec7 Bump textwrap to 0.13.2 2021-01-02 13:15:50 +08:00
Donough Liu
120e942e7a Private arg 2020-12-27 01:46:48 +08:00
Donough Liu
573dc245e6 Fix incorrect error message. 2020-12-09 01:12:58 +08:00
Pavan Kumar Sunkara
b89163afb6 Update MSRV to 1.46 2020-11-28 11:58:28 +00:00
Donough Liu
582db739c8 Shrink 2020-11-07 16:43:14 +08:00
Donough Liu
a19bfa1c35 Consistently wrap help and subcommand messages(with refactoring) 2020-10-25 22:43:01 +01:00
Jacob Mischka
b3e638ad44
Add option to hide autogenerated env section from help text 2020-10-17 16:48:35 -05:00
bors[bot]
4f90f3e4bb
Merge #2166
2166: Sort options base on option's short and long representation r=ldm0 a=ldm0



Co-authored-by: Donough Liu <ldm2993593805@163.com>
2020-10-10 18:54:49 +00:00
Donough Liu
15c77150a9 Sort options base on option's short and long representation 2020-10-11 02:08:10 +08:00
Marti Raudsepp
cda89a2af1 Fix typos and grammar
Some more fixes in addition to 594c535ba2
* Some I noticed manually.
* Some were found by Topy (https://github.com/intgr/topy), either new
  rules from Typo or new code in clap.
* `etc.` and `e.g.` rules were disabled during the last run.
2020-10-10 16:22:05 +03:00
Felix Van der Jeugt
d5c7c7d8bd
Fix clippy errors 2020-09-25 10:38:35 +02:00
Felix Van der Jeugt
0f42344685
fix(help messages): escape whitespace values in help messages 2020-09-16 15:51:33 +02:00
Alex M
3758725dc2 Fix for issue #2130. 2020-09-12 09:52:52 -07:00
Pavan Kumar Sunkara
55abd639f7 Rename get_*_no_heading to get_*_with_no_heading 2020-08-29 11:49:04 +02:00
CreepySkeleton
5020333037 Refactor coloring 2020-08-28 19:21:05 +03:00
Sergey Dubovyk
d525be42c5
chore: use if instead of matching
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-25 11:07:19 +03:00
knidarkness
530b179776 fix: detect if space should be added before spec_vals 2020-08-25 10:41:08 +03:00
Danil Kondratiev
4878f7b7b1
don't print spaces in long help 2020-08-20 17:25:36 +03:00
Matt Kantor
85d3daa8c1 Use a different default template when there are no args.
This eliminates extraneous empty lines when there are no user-defined
args, the default args are disabled, and `after_help` is set.
2020-08-14 14:02:52 -07:00
Matt Kantor
4545a47ff6 Fix: {before-help} should have fallback just like {after-help}. 2020-08-14 13:58:37 -07:00
Matt Kantor
afcacb0626 Apply wrapping to {author} and {about} template tags.
Previously wrapping was only applied to the {*-with-newline} variants.
2020-08-14 09:14:14 -07:00
Matt Kantor
059503e54d Make {before-help} and {after-help} template tags include padding.
Previously there were separate tags for this, {before-help-padded} and
{after-help-padded}. Those have been removed and the default ones
given their behavior.
2020-08-14 09:14:10 -07:00
Matt Kantor
a87320ae88 Use a template to produce the default help message.
This makes some changes to the template system:

- Template tags for optional items (like {author}) now expand to
  nothing when the value is unset instead of a default string (like
  "unknown author").
- Many template tags now emit line-wrapped output to match
  write_default_help.
- Items with long variants now expand to the appropriate thing for -h
  vs --help.
- The now-obsolete {long-about} tag has been removed.
- A few new tags have been added.

These are externally-visible changes, but if this makes it into 3.0
that's probably reasonable?

Note that line-wrapping can have some odd edge cases since it does not
account for preceding/trailing characters on the same line as the tag.
This is already the case in master, but will affect some additional
tags with this changeset. See #2065 for details.

Closes #2002.
2020-08-13 17:52:48 -07:00
bors[bot]
2df656c98d
Merge #1998
1998: Relax some restrictions on validators r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-12 14:35:39 +00:00
CreepySkeleton
18a58af3ac Allow validators to be FnMut 2020-08-12 02:39:59 +03:00
Matt Kantor
f7e2fbf150 Print an empty line after multi-line argument help.
Fixes #1642.
2020-08-11 15:30:30 -07:00