Commit graph

215 commits

Author SHA1 Message Date
Ed Page
470531b515 fix!: Replace multiple_values with number_of_values
This reduces ambiguity in how the different "multiple" parts of the API
interact and lowrs the amount of API surface area users have to dig
through to use clap.

For now, this is only a matter of cleaning up the public API.  Cleaning
up the implementation is the next step.
2022-08-01 15:50:23 -05:00
Ed Page
76bff6f34e fix!: Remove rest of deprecated APIs
Fixes #4009
2022-08-01 15:21:33 -05:00
Ed Page
41535d5c46 feat: Extend number_of_values to support min/max per occurrence 2022-07-28 16:52:25 -05:00
Ed Page
5f20fe1930 docs: Shift focus from takes_value to actions 2022-07-26 14:50:51 -05:00
Ed Page
6f03b4f948 fix!: Remove multiple occurrences in favor of Append/Count
For num_vals and friends, this only implements hacks until #2688

Fixes #3021
2022-07-25 13:23:43 -05:00
Ed Page
8aa7ab3e16 chore: Update version
The main goal is to reduce the risk of people developing on the wrong
release, assuming they are using something like starship to raise the
visibility of the crate version.
2022-07-23 21:43:37 -05:00
Ed Page
08e8642a8c
Merge pull request #3976 from epage/attrib
fix(derive)!: Remove value_parser/action defaulted attributes
2022-07-22 20:25:09 -05:00
Ed Page
6ecb7310a8 fix(derive)!: Remove value_parser/action defaulted attributes 2022-07-22 20:07:47 -05:00
Ed Page
122b562e6b fix!: Change default actions to Set/SetTrue
This is in prep for removing StoreValue/IncOccurrences
2022-07-22 20:00:47 -05:00
Ed Page
24735e3a1d fix!: Pull AppSettings out of API
Part of #3021
2022-07-22 16:05:54 -05:00
Ed Page
f10809f0cc fix!: Remove possible_values 2022-07-21 15:54:26 -05:00
Ed Page
fbd6e19f05 fix(complete)!: Remove deprecated Shell::possible_values 2022-07-21 15:40:40 -05:00
Ed Page
ff0796b014 fix(derive)!: Remove old derive names 2022-07-21 12:57:12 -05:00
Ed Page
6286339f81 docs(complete): Make example consistent
Fixes #3883
2022-07-11 15:20:45 -05:00
Ed Page
b4a1362486 chore: Release 2022-06-28 08:04:18 -05:00
Ed Page
5ba41d775c docs(license): Update years/holders
Without copyright assignment, everyone owns their own copyright, so
tried to reflect that.

See #3875
2022-06-27 12:55:09 -05:00
Ed Page
3823df9bbe chore: Release 2022-06-21 09:32:04 -05:00
Ed Page
ae78f88d48
Merge pull request #3852 from epage/msrv
chore: Bump MSRV from 1.56.0 to 1.56.1
2022-06-17 09:23:06 -05:00
Ed Page
82d70d82c4 chore: Bump MSRV from 1.56.0 to 1.56.1
Being a patch release, I'm fine doing this outside of a minor release.
This avoids us having to deal with indexmap having a higher MSRV.
2022-06-17 09:01:45 -05:00
Tshepang Mbambo
806f634bfa chore: trim Cargo manifest fields whose values are defaults
See...
- https://doc.rust-lang.org/cargo/reference/manifest.html?#the-documentation-field
- https://doc.rust-lang.org/cargo/reference/manifest.html?#the-readme-field
2022-06-17 15:49:04 +02:00
Ed Page
ea3bd55993 test(complete): Ensure we infer path completions from value_parser
Looks like I forgot to add a test case for this.

I put this in `clap_complete` because I expect `ValueHint` to move here
as we move towards a plugin system.

Fixes #3840
2022-06-16 09:59:30 -05:00
Ed Page
650a29c18b chore: Release 2022-06-13 09:37:47 -05:00
Ed Page
4e56acffce chore: Release 2022-06-13 09:31:29 -05:00
Ed Page
9e38353442 fix(derive): Clarify ArgEnum as ValueEnum
We aren't enumerating arguments but values for an argument, so the name
should reflect that.

This will be important as part of #1807 when we have more specific
attribute names.
2022-06-08 11:14:09 -05:00
Ed Page
14a62e11fd fix(parser): Deprecate multiple_occurrences
Fixes #3772
2022-06-08 09:54:23 -05:00
Ed Page
86a162d1bb fix(parser): Deprecate occurrences_of
This mostly exist for
- Knowing of the value came from the command-line but we now have
  `ArgMatches::source`
- Counting the number of flags but we now have `ArgAction::Count`
2022-06-07 13:30:32 -05:00
Ed Page
a712adefcd fix(parser): Deprecate value_of and friends 2022-05-25 12:57:11 -05:00
Ed Page
256643f8d3 fix: Deprecate possible_values 2022-05-25 12:57:11 -05:00
Ed Page
177511dab1 fix: Deprecate validator / validator_os
`validator_regex` is being ignored for now as I await on a comment
period for #3743
2022-05-25 12:57:11 -05:00
Ed Page
852a1b15d4 fix(help): Show value_parser's PossibleValues 2022-05-20 19:59:36 -05:00
Ed Page
2abb6804d3 fix: Switch to 2021 edition 2022-05-18 10:35:30 -05:00
Ed Page
d827364ea9 style: Normalize manifests 2022-05-18 10:33:37 -05:00
Ed Page
272334b26a fix: List rust-version for all crates 2022-05-18 10:08:10 -05:00
Ed Page
0033bf60c1 style: Address clippy complaints 2022-05-17 14:11:04 -05:00
Ed Page
f3d8ef248f feat(complete): Complete value_parser possible values 2022-05-16 15:08:47 -05:00
Ed Page
95698a4f31 chore: Release 2022-05-06 09:39:24 -05:00
Ed Page
3984e55363 docs(complete): Update changelog 2022-05-06 09:39:15 -05:00
Ed Page
b266e6d35d fix(complete): Complete visible, rather than hidden, values
In a refactor for #3503, one of the checks for `is_hide_set` got flipped
and we are completing hidden `PossibleValue`s rather than visible.

Fixes #3697
2022-05-06 09:14:32 -05:00
Ed Page
d3e36b1c90 fix(v4): Disallow leading dashes in long's
This is a step towards #3309.  We want to make longs and long aliases
more consistent in how they handle leading dashes.  There is more
flexibility offered in not stripping and it matches the v3 short
behavior of only taking the non-dash form.  This starts the process by
disallowing it completely so people will catch problems with it and
remove their existing leading dashes.  In a subsequent breaking release
we can remove the debug assert and allow triple-leading dashes.
2022-05-04 15:38:08 -05:00
Ed Page
0ecb6f4869 fix(builder): Fully recurse when building
Besides addressing the panic from assuming things were built when they
weren't, this should fix some completion issues for some people.

Fixes #3669
2022-04-30 20:02:06 -05:00
Ed Page
3ca1b77094 chore: Fix manifest 2022-04-30 06:37:57 -05:00
Ed Page
b01256be36 chore: Release 2022-04-30 06:36:33 -05:00
Ed Page
0c5400dadb chore: Release 2022-04-30 06:35:57 -05:00
Ed Page
09d21f4005 docs: Update changelog 2022-04-30 06:35:38 -05:00
Ed Page
1922b892ae fix(complete): Correctly detect positionals 2022-04-27 15:53:02 -05:00
Ed Page
53ae382c99 feat(complete): Add debug aids 2022-04-27 15:49:58 -05:00
Ed Page
4b9dd3fbbb test(complete): Cover long flags 2022-04-27 15:49:58 -05:00
Ed Page
c9b6d62ba7 test(complete): Cover subcommands 2022-04-27 15:49:58 -05:00
Ed Page
ca4439a93a fix(complete): Make short flags additive 2022-04-27 15:49:58 -05:00
Ed Page
f4892848da fix(complete): Allow subcommands in escaped arguments 2022-04-27 15:49:58 -05:00
Ed Page
6895806566 fix(complete: Use correct value name for IFS 2022-04-27 15:49:58 -05:00
Ed Page
2701f48023 fix(complete): Don't require IFS
This makes testing easier
2022-04-27 15:49:58 -05:00
Ed Page
fe70fbc733 fix(complete): Only use IFS between items 2022-04-27 15:49:58 -05:00
Ed Page
a574f226eb feat(complete): Look up partial matches 2022-04-27 15:49:58 -05:00
Ed Page
63e0fd5c50 fix(complete): Don't count flags as positionals 2022-04-27 15:49:58 -05:00
Ed Page
0112ad8b4f refactor(complete): Extract arg value completion 2022-04-27 15:49:58 -05:00
Ed Page
458b4ae9cc feat(complete): Escaped args are always positional 2022-04-27 15:49:58 -05:00
Ed Page
44443503cc feat(complete): Only list for current positional 2022-04-27 15:49:58 -05:00
Ed Page
2d70927be6 fix(complete): Detect which argument is being completed 2022-04-27 15:49:58 -05:00
Ed Page
018b8bd565 feat(complete): Complete possible values 2022-04-27 15:49:58 -05:00
Ed Page
5882e3df3b feat(complete): Basic subcommand support 2022-04-27 15:49:58 -05:00
Ed Page
9f9e410c6d feat(complete): Minimal rust-completion
Inspired by argcomplete, this provides Rust-implemented completions
- Only bash for now
- No subcommand support
- No flag value support
- No special settings support
- No handling of positions within positionals
- No prioritizing of required or removing of conflicts (including
  self-conflicts)
2022-04-27 15:49:58 -05:00
Ed Page
bbf6488ede fix(complete): Send debug statements to stderr 2022-04-27 15:49:58 -05:00
Ed Page
3d64ebacac test(complete): Option to verify examples 2022-04-27 09:03:47 -05:00
Ed Page
89c2b3bb0d docs(complete): Clarify examples 2022-04-27 08:55:12 -05:00
Ed Page
55bfacbf43 test(complete): Use official extensions for snapshots 2022-04-22 16:21:10 -05:00
Ed Page
0194568b03 chore: Release 2022-04-19 10:31:52 -05:00
Ed Page
8f182067e3 feat(clap): Publicly expose Command::build
`Command::_build_all` started as an internal function for
`clap_complete` as a stopgap until #2911.  Overtime, we've been finding
more cases where this function needs to be called, so now we're going to
fully embrace it until #2911 so people aren't scrared off by the hidden
implementation from using it.

This was inspired by #3602

Comptibility: Though this adds a deprecation which we general reserve
for minor or major versions, this is enough of a corner case that I'm
fine doing this in a patch release.
2022-04-19 10:13:43 -05:00
Federico Ciardi
5689adc875 fix(clap_complete_fig): Correct requiresEquals name and add it to the right objects 2022-03-18 14:46:20 +01:00
Federico Ciardi
abc72a7d0b feat(clap_complete_fig): Add exclusiveOn and isRepeatable 2022-03-17 21:47:18 +01:00
Federico Ciardi
f755198349
feat(clap_complete_fig): support hide and require_equals (#3560) 2022-03-17 20:35:52 +00:00
Ed Page
02fe7659c0 test(complete): Switch to snapshot testing
- This will make it easier to update
- We now uniformly test each shell
2022-03-07 14:03:49 -06:00
Ed Page
1e286f3dc2 chore: Release 2022-03-02 09:20:00 -06:00
Roland Fredenhagen
33949ce4de
feat(help): Show PossibleValue help in --help (#3503)
`-h` (short help) still shows the same.

This gates it behind an `unstable-v4` feature flag to avoid disrupting users who set the help without knowing where all it shows up (particularly derive users where `ArgEnum` is automatically extracting the help).

Fixes #3312
2022-03-02 09:15:28 -06:00
Ed Page
e6729f96c3 chore: Release 2022-02-16 11:59:45 -06:00
Ed Page
94c7775a30 docs: Update changelogs 2022-02-15 10:49:00 -06:00
Ed Page
ddac492302 fix: Rename IntoApp to CommandFactory
This is part of the `App` rename.

Previously, I was concerned about not being able to deprecate

For backwards compatibility, we still expose the `IntoApp` name.
2022-02-15 08:24:00 -06:00
Ed Page
c3fec1fa75 fix: Update derive->Command function name
No good solution for transitioning the trate name, unfortnately, since
we can't mark `use`s as deprecated (we can, it just does nothing).

I got rid of the `into` prefix because that implies a `self` parameter
that doesn't exist.
2022-02-14 16:04:10 -06:00
Ed Page
e8010e79a9 refactor: Update app variables to cmd 2022-02-14 15:55:56 -06:00
Ed Page
c4144d7d6c docs: Update App references to Command 2022-02-14 15:33:49 -06:00
Gibson Fahnestock
6f36ca3a25
fix(complete): escape fish possible values
Fixes: https://github.com/clap-rs/clap/issues/3467
2022-02-14 20:58:57 +00:00
Gibson Fahnestock
0fbabaa3fe
test(completion): add regression test for fish quoting issue 2022-02-14 20:55:06 +00:00
Ed Page
1e4ec5f4f0 fix: Deprecation warnings 2022-02-11 15:59:03 -06:00
Ed Page
d3f5d7ce34 fix: Clarify Arg/ArgGroup id's role
This adjusts names.  Adjusting the derive naming (and re-naming) is left
to #2475.

Fixes #3335
2022-02-11 14:11:50 -06:00
Ed Page
272f840178 feat: Replace core set of AppSettings with functions
This is a part of #2717

Some settings didn't get getters because
- They are transient parse settings (e.g. ignore errors)
- They get propagated to args and should be checked there

`is_allow_hyphen_values_set` is a curious case.  In some cases, we only
check the app and not an arg.  This seems suspicious.
2022-02-11 12:35:09 -06:00
Ed Page
9bd7060089 fix: Deprecate various APIs
- ArgSettings are part of #2717
- Errors are part of #2628
- `help_heading` is part of #1807 and #1553
- Some misc parts are for API consistency
2022-02-10 19:37:47 -06:00
Ed Page
47d76742eb feat: Add Arg getters for all settings
This is prep for #2717
2022-02-10 10:18:41 -06:00
Ed Page
5c3868ea4c chore: Release 2022-02-05 09:33:39 -06:00
Ed Page
28ea108374 docs: Update changelog 2022-02-05 09:33:12 -06:00
Haim Ashkenazi
c90a48bf0b More failing tests, hope this will end it :( 2022-02-05 17:16:40 +02:00
Haim Ashkenazi
3c2cea9754 Fixed failing test 2022-02-05 17:09:06 +02:00
Haim Ashkenazi
bf98b1bded Allow completion of partial commands
Based on solution suggested here by @benedictleejh:
    https://github.com/clap-rs/clap/issues/2750
2022-02-05 16:49:21 +02:00
Ed Page
e5b06c3061 chore: Release 2022-01-24 10:54:50 -06:00
Ed Page
ac43b7baee docs: Update changelog 2022-01-24 10:54:04 -06:00
Ed Page
afb2a3dd05 docs(complete): Clarify some panic conditions 2022-01-21 08:29:38 -06:00
Ed Page
b488aab46c fix: Clarify some unwraps as expects
This was inspiredby #3322
2022-01-21 08:27:18 -06:00
Ed Page
4a43b51a42 fix(complete): Handle help completions
The main motivation was to reduce special cases by putting all of the
logic in one place.
2022-01-17 09:23:04 -06:00
Ed Page
7b7c76e3d0 chore: Release 2022-01-15 18:51:41 -06:00
Ed Page
1c89abaa5b docs: Update changelog 2022-01-15 18:51:23 -06:00
Clifton King
658b7a0841 fix(complete): Fix unescaped single quotes in zsh
help strings for subcomand args did not escape single quotes
2022-01-15 14:33:11 -06:00
rndhouse
85cac43672
Fix broken CONTRIBUTING.md URL. 2022-01-13 15:14:08 +00:00
Ed Page
3d8ce3f426 chore: Release 2022-01-12 11:12:42 -06:00
Ed Page
0439dc221f docs: Update changelogs 2022-01-12 11:11:53 -06:00
Ed Page
37f47dd260 docs: Add completion changelogs 2022-01-12 11:04:57 -06:00
cherryblossom
6d27488602
fix(complete): Use Elvish v0.17 lambda syntax
[Elvish v0.17][1] deprecated the old lambda syntax (`[arg1 arg2] { body }`)
in favour of the new `{|arg1 arg2| body }` syntax. This commit uses the
new syntax to stop deprecation warnings.

[1]: https://elv.sh/blog/0.17.0-release-notes.html#deprecated-features
2022-01-12 11:58:18 +11:00
xylous
e2f4d2827e
fix(complete): Add newline at end of zsh output 2022-01-09 19:51:18 +02:00
Ed Page
d9906eb150 chore: Release 2022-01-04 09:49:41 -06:00
Daniel Eades
7f71d642cd style: prefer 'char' to 'str' for single character patterns 2022-01-04 09:20:08 -06:00
Ed Page
d392b88bd5 chore: Release 2022-01-03 12:12:28 -06:00
Marti Raudsepp
f10c5d18d9 docs(complete): Fix imports in documentation
Use `shells::Bash` instead of `generators::Bash`
2022-01-02 21:10:18 +02:00
Ed Page
c01ebbac17 chore: Release 2021-12-31 14:35:02 -06:00
Ed Page
bc951e4e53 chore: Release 2021-12-31 13:37:28 -06:00
Ed Page
19b59a2df8 fix(complete): Better organize the API 2021-12-31 13:25:09 -06:00
Ed Page
8d73a0e80f chore: Release 2021-12-31 12:23:47 -06:00
Ed Page
88a335ff97 fix(complete): Give crates more specific names
`clap_generate` originally intended to be "generate anything".  With
`fig`, we already broke one part out.  With #3174's man support, we are
also looking at keeping it separate:
- More freedom to iterate on the API
- Uniqueness (and potential weight) of its dependencies
- man generation is normally more for distribution while completions are
  a mix of being distributed with the app or the app generating the
  completions (which will be exacerbated if we move most completion
  parsing logic to be in Rust)

So `clap_generate` is having a lot more limited of a role than the
original name conveys.   I worry the generic name will be a hindrance to
people discovering and using it (yes, documentation can help but there
are limits).

I hesitated because we are on the verge of releasing 3.0. However, doing
it even later will be even more disruptive because more people will be
using it (crates.io lists ~70 people using `clap_generate`).

To ease things, we are still releasing `clap_generate` as a wrapper
around `clap_complete`.
2021-12-31 12:03:29 -06:00