Commit graph

117 commits

Author SHA1 Message Date
Ed Page
1bbf07e574 fix: Prefer more usable &str for reflection
The downside is we can't skip allocations with
- `ValueEnum` default values
- Vaid subcommands

Otherwise, this is a big ergonomic win.
2022-08-22 14:56:16 -05:00
Ed Page
85f541d789 fix: Switch to owned types
Impact:
- Binary size: 556.6 KiB to 578.4 KiB
- build time: 6.4950 us (7% slower)
- parse time: 7.7256 us
- parse sc time: 8.1580 us (5% faster)

Fixes #1041
Fixes #2150
2022-08-22 14:55:55 -05:00
grant0417
fedda32167 feat(fig): escape all strings 2022-08-21 00:46:32 -07:00
Ed Page
3390adf0d3 chore: Bump MSRV to 1.60.0
While at it, this cleans up all of the features.  For some reason, I
couldn't do `dep:clap_derive` though.
2022-08-10 21:32:06 -05:00
Ed Page
f70ebe89a7 fix!: Require explicit help/version disabling
Before we introduced actions, it required specific setups to engage with
claps version and help printing.  With actions making that more
explicit, we don't get as much benefit from our multiple, obscure, ways
of users customizing help

Before
- Modify existing help or version with `mut_arg` which would
  automatically be pushed down the command tree like `global(true)`
- Create an new help or version and have it treated as if it was the
  built-in on (I think)
- Use the same flags as built-in and have the built-in flags
  automatically disabled
- Users could explicitly disable the built-in functionality and do what
  they want

Now
- `mut_arg` no longer works as we define help and version flags at the
  end
- If someone defines a flag that overlaps with the built-ins by id,
  long, or short, a debug assert will tell them to explicitly disable
  the built-in
- Any customization has to be done by a user providing their own.  To
  propagate through the command tree, they need to set `global(true)`.

Benefits
- Hopefully, this makes it less confusing on how to override help
  behavior.  Someone creates an arg and we then tell them how to disable
  the built-in
- This greatly simplifies the arg handling by pushing more
  responsibility onto the developer in what are hopefully just corner
  cases
- This removes about 1Kb from .text

Fixes #3405
Fixes #4033
2022-08-10 20:33:21 -05:00
Ed Page
64639aa81c style: Make clippy happy 2022-08-10 11:41:27 -05:00
Ed Page
8ed35b4d9f fix: Provide convenient access for common cases 2022-08-05 12:06:54 -05:00
Ed Page
32f308d4ef fix!: Make is_multiple_values private
multiple_values is now just book keeping for the builder, instead people
should look to actions and `num_args`.

The meaning for it was a little weird anyways.
2022-08-04 15:21:10 -05:00
Ed Page
6e1ca59ec1 fix!: Make is_takes_value_set private
At this point, it is an implementation detail to help with book keeping
within the builder.
2022-08-04 14:44:14 -05:00
Ed Page
ba15b5f430 fix!: Rename Arg::number_of_values to Arg::num_args 2022-08-03 14:45:47 -05:00
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
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
50259e51d5 fix!: Remove deprecated ArgActions 2022-07-22 20:07:24 -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
f495827126 chore: Release 2022-07-01 19:48:03 -05:00
Ed Page
51ad0dd155 docs: Update changelog 2022-07-01 19:47:49 -05:00
grant0417
85b1b7711a fix: Add back depercated is_multiple_occurrences_set 2022-07-01 11:48:56 -07:00
grant0417
4cf9f392ae fix: Run cargo fmt 2022-06-28 18:38:43 -07:00
grant0417
0025944d9e feat(clap_complete_fig): Switch to using ArgAction 2022-06-28 18:30:39 -07: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
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
14a62e11fd fix(parser): Deprecate multiple_occurrences
Fixes #3772
2022-06-08 09:54:23 -05:00
Ed Page
256643f8d3 fix: Deprecate possible_values 2022-05-25 12:57:11 -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
f3d8ef248f feat(complete): Complete value_parser possible values 2022-05-16 15:08:47 -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
0194568b03 chore: Release 2022-04-19 10:31:52 -05:00
Ed Page
5176e59794 chore: Release 2022-03-21 07:10:11 -05:00
Ed Page
f3185f4773 docs(fig): Update changelog 2022-03-21 07:09:49 -05:00
Federico Ciardi
a404ab8680 feat(clap_complete_fig): Add subcommand aliases support 2022-03-20 21:21:03 +01:00
Ed Page
fb39216caf chore: Release 2022-03-18 08:58:33 -05:00
Ed Page
077793aca4 chore: Release 2022-03-18 08:57:36 -05:00
Ed Page
c029156fbf
Merge pull request #3562 from fedeci/fix/correct-name
fix(clap_complete_fig): Correct `requiresEquals` name and add it to the right objects
2022-03-18 08:57:06 -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
Ed Page
20443fe5a5 chore: Release 2022-03-17 16:20:34 -05:00
Federico Ciardi
791d43254c fix(clap_complete_fig): Correct indentation and spacing
Co-Authored-By: Grant G <grantgurvis@gmail.com>
2022-03-17 21:50:10 +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
003b0052bb test(fig): Switch to snapshot testing 2022-03-07 14:08:56 -06:00
Ed Page
e6729f96c3 chore: Release 2022-02-16 11:59:45 -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
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
47d76742eb feat: Add Arg getters for all settings
This is prep for #2717
2022-02-10 10:18:41 -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
3d8ce3f426 chore: Release 2022-01-12 11:12:42 -06:00
Ed Page
37f47dd260 docs: Add completion changelogs 2022-01-12 11:04:57 -06: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
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