Commit graph

4017 commits

Author SHA1 Message Date
ModProg
480035ac9c ArgEnum: Slice instead of array, from_str in ArgEnum implemented 2021-09-29 18:33:43 +02:00
ModProg
ac1a9d6d13 address epage's remarks 2021-09-27 22:06:17 +02:00
ModProg
76f7211d8b small changes 2021-09-27 01:29:10 +02:00
ModProg
f002cdcc99 move alias implementation to ArgValue for derive 2021-09-27 01:18:47 +02:00
ModProg
d3f0534939 add hidden aliases to ArgValue 2021-09-26 22:46:23 +02:00
Roland Fredenhagen
88d7d02555 Working Implementation 2021-09-26 16:32:46 +02:00
ModProg
b589a6ce06 feat(derive:arg_enum): use ArgValue in ArgEnum trait 2021-09-26 16:32:46 +02:00
Pavan Kumar Sunkara
86fda8bacd
Merge pull request #2786 from jonathanmorley/assert-whitespace
assert on leading and trailing whitespace
2021-09-24 20:25:17 +01:00
Morley, Jonathan
1d3a292d6b assert on leading and trailing whitespace 2021-09-24 12:38:15 -04:00
Pavan Kumar Sunkara
f243bbf06d
Merge pull request #2781 from clap-rs/settings_bitor
Implement BitOr for settings
2021-09-24 16:14:51 +01:00
Pavan Kumar Sunkara
9c214a66dc
Merge pull request #2783 from cherryblossom000/elvish-completions-fix
Fix Elvish completions generation
2021-09-24 14:39:00 +01:00
cherryblossom
f77dceaf69
Fix Elvish completions generation
The `display-suffix` option for `edit:complex-candidate` was [deprecated in Elvish v0.14.0][1] and
removed in v0.15.0 (latest version is v0.16.3), so this commit changes the Elvish completions
generation to use the `display` option instead.

Additionally, this commit changes assignments to use the `var` and `set` keywords as using
`name = value` without these keywords ('legacy assignment form') [will be deprecated][2].

[1]: https://elv.sh/blog/0.14.0-release-notes.html
[2]: https://elv.sh/ref/language.html#legacy-assignment-form
2021-09-24 22:29:05 +10:00
Pavan Kumar Sunkara
bdc70c9fd9 Fix benchmarking issues 2021-09-23 17:17:15 +05:30
Pavan Kumar Sunkara
699a3f76d6 Implement BitOr for settings 2021-09-23 14:57:10 +05:30
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
Pavan Kumar Sunkara
a42a97a566
Merge pull request #2775 from patrick-gu/master
Apply `value_delimiter` to default values
2021-09-19 00:55:39 +01:00
patrick-gu
d79c59ab17 Add test for default_missing_values with value_delimiter 2021-09-18 15:47:03 -07:00
patrick-gu
90dde89ec4 Apply value_delimiter to default values 2021-09-18 15:15:25 -07:00
Pavan Kumar Sunkara
c4780e3305
Merge pull request #2774 from epage/vec_map
refactor: Remove vec_map dependency
2021-09-18 11:38:46 +01:00
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
Pavan Kumar Sunkara
1937472e0f
Merge pull request #2771 from mustafa-guler/master
Fix bug with duplicate error messages
2021-09-17 19:28:43 +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
Pavan Kumar Sunkara
af7802a2ed
Merge pull request #2761 from ModProg/patch-1
doc(generate) fix link in `generate_to`
2021-09-09 16:35:12 +01:00
Roland Fredenhagen
c01df8da40
doc(generate) fix link in generate_to 2021-09-09 13:04:01 +02:00
Roland Fredenhagen
0105e6f0b8
fix(generate): Better subcommand completion in fish (#2726)
* fix(generate): Better subcommand completion in fish

* Prevent completing subcommands that were already completed

* Make sure all parent subcommands actually existent

Partially fixes #2715

* Added Test

* fix(generate) Improve subcommand testing

This now also disables the completion of sub_subcommands options for
subcommands.
2021-09-08 15:32:26 +01:00
Pavan Kumar Sunkara
d03638c0fd
Merge pull request #2751 from co42/derive_subcmd_name_not_literal
Allow subcmd name to be something else than a literal in clap derive
2021-09-07 08:40:54 +01:00
corentin.regal
8df90fbd0e Allow subcmd name to be something else than a literal in clap derive 2021-09-06 09:13:20 +02: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
Pavan Kumar Sunkara
b8ceab3e6f Fixes #2736 2021-09-04 15:04:09 +05:30
Pavan Kumar Sunkara
dae86f456e
Merge pull request #2744 from dylni/replace-arg-str-with-raw-os-str
Replace `ArgStr` with `os_str_bytes::RawOsStr`
2021-08-31 21:19:02 +01:00
Emmanuel Leblond
15b9ff1a24
Add placeholders for Cookbook and Cheatsheet pages in the website (#2732)
* Add placeholders for Cookbook and Cheatsheet pages in the website

* Update site/content/cheatsheet.md

Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-08-31 11:13:21 +00:00
Pavan Kumar Sunkara
09ec8bd1db
Merge pull request #2747 from svenstaro/fix-keyvalue-example
Fix keyvalue example
2021-08-30 05:00:02 +01:00
Sven-Hendrik Haase
2f8f55e64b
Fix keyvalue example
This was broken earlier due to 3f94d17c71 not
taking into account this example.

Fixes #2746.
2021-08-30 04:52:35 +02:00
dylni
6311c894cc Fix compile errors 2021-08-29 10:24:56 -04:00
dylni
a50591b16b Fix warnings 2021-08-29 10:10:26 -04:00
dylni
dc65513966 Replace ArgStr with os_str_bytes::RawOsStr 2021-08-29 10:00:30 -04:00
Pavan Kumar Sunkara
ee67039c5e
Merge pull request #2743 from ldm0/error_send_sync
Make `clap::Error` `Send` and `Sync` again
2021-08-29 11:29:19 +01:00
liudingming
898894cf35 Make clap::Error Send and Sync again 2021-08-29 17:21:08 +08:00
liudingming
f200828045 Add regression test 2021-08-29 17:21:08 +08:00
Pavan Kumar Sunkara
d0fd6df6d2
Merge pull request #2730 from ModProg/fish-argenum-hide-description
fix(generate): Hide option/argument description for argenum
2021-08-25 16:48:27 +01:00
ModProg
f6ccf07de4 Fix Formatting 2021-08-21 01:00:51 +02:00
ModProg
174e004107 fix(generate): Hide option/argument description for argenum
This returns `"{a\t,b\t}"` instead of `"a b"` for possible_values
completion. Therefore fish displays and therefor hides the empty
description after the `\t`.

Fixes #2727
2021-08-21 00:53:10 +02:00
Pavan Kumar Sunkara
f085fa64f4
Merge pull request #2722 from epage/group
fix(yaml): Don't panic on multiple groups
2021-08-19 07:40:41 +01:00
Pavan Kumar Sunkara
6512950e13
Merge pull request #2677 from epage/utf8
fix: Provide path to avoid UTF-8 panics
2021-08-18 22:50:42 +01:00
Ed Page
bd25b5f615 fix(yaml): Don't panic on multiple groups
Because we gradually build the `ArgGroup` as we parse the YAML, we don't
use `ArgGroup::new`.  Clap3 introduced an internal `id` in addition to
the public `name` and it appears that this custom initialization code
was not updated.

This shows the problem with publically exposing `impl Default`.
Choices:
- Remove `impl Default`
  - Always valid
  - Requires spreading invariants
  - Callers can't implement code the same way we do
- Add `ArgGroup::name`
  - Can be constructed in an invalid state
  - Centralizes invariants
  - A caller could implement code like the yaml logic

I decided to go with `ArgGroup::name`.

Fixes #2719
2021-08-18 15:16:44 -05:00
Ed Page
aeaf01e3e7 fix: Provide path to avoid UTF-8 panics
Before, validating UTF-8 was all-or-nothing and would cause a `panic` if
someone used the right API with non-UTF-8 input.

Now, all arguments are validated for UTF-8, unless opted-out.  This
ensures a non-panicing path forward at the cost of people using the
builder API that previously did `value_of_os` need to now set this flag.

Fixes #751
2021-08-18 14:15:18 -05:00
Pavan Kumar Sunkara
2fd26423e2
Merge pull request #2720 from epage/generate
docs(generate): Improve jumping off points
2021-08-18 19:51:35 +01:00
Ed Page
f2586c920f docs: Point out alternatives to 'build.rs' 2021-08-18 12:10:04 -05:00