Commit graph

633 commits

Author SHA1 Message Date
Ed Page
94c5802aae docs: Update changelog 2022-09-19 09:28:56 -05:00
Ed Page
acb0fb7809 fix: Generalize mut_arg, like mut_subcommand
This makes us accept `str` and not do any allocations at the cost of
panicing if unsupported which I think fits our overall story in trying
to catch development-time errors.
2022-09-16 15:31:49 -05:00
Ed Page
14c6ce0e83 fix(derive): Remove next_help_heading isolation
Originally, I saw the ideal as the parent command being isolated from
`#[clap(flatte)]` especially after all of the doc comment
leakage issues.  We scaled that back to just `next_help_heading` because
of the issues with settling on a policy and maintenance to cover
everything.  When doing `next_display_order`, we decided it would mess
things up too much to isolate it.

With #1807, we instead have been moving towards setting
`#[command(next_help_heading)]` anywhere, we just need to finish working
out how it should work.
2022-09-16 15:31:49 -05:00
Ed Page
b7d13dfb88 fix(parser): Prefer invalid subcommands over invalid args
Just having `--help` or `--version` can make us get invalid args instead
of invalid subcommands.   It doesn't make sense to do this unless
positionals are used.  Even then it might not make sense but this is at
least a step in the right direction.

Unsure how I feel about this being backported to clap 3.  It most likely
would be fine?

This was noticed while looking into #4218
2022-09-15 10:30:03 -05:00
Ed Page
23ce67e323 feat: Allow resetting builder methods
Fixes #4178
2022-09-13 15:16:57 -05:00
Ed Page
f68500d9fd fix: Replace Arg::env with Arg::env_os
With `Into<OsStr>`, the separate function isn't needed.
2022-09-13 14:55:12 -05:00
Ed Page
d3bf5450ff feat(derive): Reserve the T group name
Since the `name` is changed to be the package name, we can't use it as
(1) its not as predictable and (2) it can lead to conflicts if a
`Parser` is flattened into a `Parser`
2022-09-13 07:44:36 -05:00
Ed Page
0eb95022a5 fix(help): Respect LINES and COLUMNS
Fixes #4186
2022-09-12 20:17:20 -05:00
Ed Page
c9eef44213 fix: Make arg!(--flag <value>) optional by default
This was ported over from the usage parser which modeled after docopt.
We just never got around to implementing the rest of the syntax.

However, when considering this as a standalone feature, an
`arg!(--flag <value>)`, outside of other context, should be optional.
This is how the help would display it.

Fixes #4206
2022-09-12 17:10:01 -05:00
Ed Page
75a73f3fe0 docs: Feature moved to v3 2022-09-12 16:25:18 -05:00
Ed Page
a86e55ad3e docs: Add more highlights 2022-09-09 19:06:33 -05:00
Ed Page
fadcaf9860 docs: Help people through Action changes 2022-09-08 16:02:12 -05:00
Ed Page
6f185a8704 docs: Clarify intent of upgrade link 2022-09-08 15:56:56 -05:00
Ed Page
17f49df4e2 revert(derive): Bald action/value_parser are deprecated, its good enough
When I removed these in v5, we didn't have a deprecation approach for
the derive and I didn't want to forget.  Now we do have a deprecation
approach and that is the reminder, so we don't need to carry around v5
changes.
2022-09-07 19:34:50 -05:00
Ed Page
b502ac750b docs: Summarize reason for change 2022-09-07 19:30:57 -05:00
Ed Page
c90a4eabae fix(help): Make output more dense
In looking at other help output, I noticed that they use two spaces, in
place of clap's 4, and it doesn't suffer from legibility.  If it
doesn't make the output worse, let's go ahead and make it as dense so we
fit more content on the screen.

This is a part of #4132
2022-09-07 17:13:55 -05:00
Ed Page
bbb6c38bad fix(help):Be dense on short next line help
If short help is too long for the terminal, clap will automatically
switch to next line help.  As part of next line help for longs, we add a
blank line between args.  This helps make the args clearer when dealing
with multiple paragraphs.  However, its not as much needed for short and
subcommands (always short), so now short matches subcommands.

This was inspired by #3300 and a part of #4132
2022-09-07 14:05:17 -05:00
Ed Page
69dd145767 docs: Fix code fence 2022-09-07 13:40:03 -05:00
Ed Page
b7b12ea558 docs: Add another highlighted difference 2022-09-07 12:45:25 -05:00
Ed Page
55e2297174 docs: Write v4 migration 2022-09-07 12:43:57 -05:00
Ed Page
1258f3e5f6 fix: Deprecate Command::allow_negative_numbers
Better to set on individual args
2022-09-07 07:24:42 -05:00
Ed Page
d45e4be14b fix(derive): Deprecate Command::allow_hyphen_values
Fixes #3450
2022-09-06 20:50:09 -05:00
Ed Page
bc5c5e4a9f fix(parser): Make Command/Arg behave same for shorts with allow_hyphen_values 2022-09-06 19:41:17 -05:00
Ed Page
bffce7f57a fix: Deprecate Command::trailing_var_arg
Now that we have it on `Arg`, we don't need it on `Command`
2022-09-06 19:41:17 -05:00
Ed Page
47e3cb6498 docs: Update changelog 2022-09-02 15:44:41 -05:00
Ed Page
7b0c76de31 Revert "fix(derive): Remove structopt attribute support"
This reverts commit 521a012c28.
2022-09-02 11:15:15 -05:00
Ed Page
439c9e7a91 feat(help): Expose clap's indentation to help_template
This will make it easier for help templates to be consistent with clap
2022-08-31 15:42:59 -05:00
Ed Page
65b5b5f7bf fix(help): Remove name/version/author from help
This is to help shorten it and polish it by removing redundant
information.

This is a part of #4132
2022-08-31 15:06:15 -05:00
Ed Page
c1c269b427 fix(help): Clarify short vs long help
In reviewing CLIs for #4132, I found some were providing helps on `-h`
vs `--help` and figured that could be built directly into clap.  I had
considered not making this hint automatic but I figured the overhead of
checking if long exists wouldn't be too bad.  The code exists (no binary
size increase) and just a simple iteration is probably not too slow
compared to everything else.

Fixes #1015
2022-08-31 14:25:46 -05:00
Ed Page
cdfd455ee6 fix(help): Always trim output
This ensures we don't end up with accidental leading or trailing
newlines due to help template variables not being used when a section is
empty.

This is prep for removing name/version from the default template and is
part of #4132
2022-08-31 09:35:33 -05:00
Ed Page
87cc6f9a1e docs: Add workaround to changelog 2022-08-31 09:06:43 -05:00
Ed Page
42c943844c fix(help): Use Command in place of Subcommand
In switching to title case for help headings (#4123), it caused me to
look at "subcommand" in a fresh light.  I can't quite put my finger on
it but "Subcommand" looks a bit sloppy.  I also have recently been
surveying other CLIs and they just use "command" as well.

All of them are commands anyways, just some are children of others
(subcommands) while others are not (root or top-level commands, or just
command).  Context is good enough for clarifying subcommands from root
commands.

This is part of #4132
2022-08-31 08:53:10 -05:00
Ed Page
3f44dc03d2 docs: Provide workaround for title cased headings 2022-08-30 19:59:42 -05:00
Ed Page
44d3614add revert: Add some deprecated placeholders 2022-08-30 16:47:39 -05:00
Ed Page
1ca4bab206 docs: Update references in changelog 2022-08-30 16:34:20 -05:00
Ed Page
b632b4434f docs: Fix link in changelog 2022-08-30 16:32:12 -05:00
Ed Page
02d27b5ce3 fix(usage): Make dont_collapse_args_in_usage the default
The setting was added to resolve #769.  The reason it was optional is out
of concern for applications with a lot of positional arguments.  I think
those cases are rare enough that we should just push people to override
the usage.  Positional arguments are generally important enough, even if
optional, to show.

As a side effect, this fixed some bugs with
`dont_collapse_args_in_usage` where it would repeat an argument in a
smart usage.

As a side effect, smart usage now shows `--` when it should
2022-08-30 16:12:49 -05:00
Ed Page
f3c4bfd993 docs: Forward integrate v3's changelog 2022-08-30 08:54:00 -05:00
Ed Page
5bbe04ac2a docs: Update changelog 2022-08-29 16:50:04 -05:00
Ed Page
36460aed08 fix: Deprecate _os variants
PR #4096 made them redundant
2022-08-29 12:42:30 -05:00
Ed Page
a2f3ee2cfa docs: Update changelog 2022-08-26 20:06:46 -05:00
Ed Page
521a012c28 fix(derive): Remove structopt attribute support 2022-08-26 16:06:10 -05:00
Ed Page
b4b121d3a4 fix(derive): Remove deprecated arg_enum attribute 2022-08-26 13:34:16 -05:00
Ed Page
83d6add9aa fix(help): Shift focus to subcommands, when present
In surveying various tools and CLI parsers, I noticed they list the
subcommands first.  This puts an emphasis on them which makes sense
because that is most likely what an end user is supposed to pass in
next.

Listing them last aligns with the usage order but it probably doesn't
outweigh the value of getting a user moving forward.
2022-08-26 10:59:40 -05:00
Ed Page
9b23a09f7a fix(help): Don't rely on ALL CAPS for headers
I see them fulfilling two roles
- A form of bolding
- As a callback to their placeholder in usage

However, it is a bit of an unpolished look and no other CLI seems to do
it.  This looks a bit more proefessional.  We have colored help for
formatting and I think the sections relation to usage will be clear
enough.
2022-08-26 10:21:18 -05:00
Ed Page
6079a871a0 fix(help): Use a more neutral palette
Fixes #2963
2022-08-25 19:23:52 -05:00
Ed Page
ef5f9f956a perf(error): Allow custmizing formatting
For now, there isn't much a custom implementation can do.

Going from `Rich` to `Null` drops about 6 KiB from the binary

This is a part of #1365 and #1384
2022-08-24 12:40:21 -05:00
Ed Page
c6b8a7bafc docs: Update changelog 2022-08-22 19:47:05 -05:00
Ed Page
9074b60194 feat(parser): Make customizeing flags easier
While `TypedValueParser` will generally make it easier to reuse value
parsers, this was particularly written for flags.  Besides having a
concrete API to document, an advantage over `fn(&str) -> Result<bool, E>`
value parsers is you get all of the benefits of the existing value
parsers for environment variable parsing.
2022-08-19 08:21:55 -05:00
Ed Page
cf7d78692b
Merge pull request #4092 from epage/flag
fix: Allow non-bool value_parsers for SetTrue
2022-08-18 21:52:31 -05:00
Ed Page
09354dec21 fix: Allow non-bool value_parsers for SetTrue
Not sure if we could have originally made this work but it definitely
does now that we use `default_missing_value` for this (#4000)
2022-08-18 21:35:29 -05:00
Orhun Parmaksız
97b0feffed
docs: Fix typo in changelog 2022-08-16 20:19:03 +02:00
Ed Page
09288b4bb9 fix!: Require/default conditional APIs are more explicit
This helps with
- API cleanup by not having ambigious `None`, see #950
- Removes ambiguity with `None` when using owned/borrowed types for
  #1041
2022-08-16 11:52:10 -05:00
Ed Page
30d4ef4b09 fix: Allow OsStr for some required_if_eq calls 2022-08-16 10:22:24 -05:00
Ed Page
2de59195aa fix!: Prefer IntoIterator over &[]
The main breakinge change cases:
- `&[char]`: now requires removing `&`
- All other non-ID `&[_]`: hopefully #1041 will make these non-breaking

Fixes #2870
2022-08-15 13:26:17 -05:00
Ed Page
41be1bed08 fix(parser)!: Store args in a group, rather than values
Now that `Id` is public, we can have `ArgMatches` report them.  If we
have to choose one behavior, this is more universal.  The user can still
look up the values, this works with groups whose args have different
types, and this allows people to make decisions off of it when otherwise
there isn't enogh information.

Fixes #2317
Fixes #3748
2022-08-12 16:40:07 -05:00
Ed Page
f84e38a4de fix!: Switch from &[] to IntoIterator
This is a part of #2870 and is prep for #1041

Oddly enough, this dropped the binary size by 200 Bytes

Compared to `HEAD~` on `06_rustup`:
- build: 6.21us -> 6.23us
- parse: 7.55us -> 8.17us
- parse_sc: 7.95us -> 7.65us
2022-08-12 15:45:02 -05: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
c801e4e56e fix!: Make ArgAction::Set the default
This removes the need for `TakesValue` bookkeeping for when we knew we
took values but didn't know how many we should take.

Fixes #2687
2022-08-05 13:31:33 -05:00
Ed Page
c62d3f0cfd fix!: Replace takes_value with number_of_values 2022-08-04 09:39:25 -05:00
Ed Page
85ad452c9b fix!: Remove Arg::rwquire_value_delimiter
In clap v3, `require_value_delimiter` activated an alternative parse
mode where
- `multiple_values` meant "multiple values within a single arg"
- `number_of_values` having no parse impact, only validation impact
- `value_names` being delimited values

For unbounded `number_of_values`, this is exactly what `value_delimiter`
provides.  The only value is if someone wanted `value_name` to be
`<file1>,<file2>,...` which can be useful and we might look into adding
back in.

Alternatively, this could be used for cases like key-value pairs but
that has issues like not allowing the delimiter in the value which might
be ok in some cases but not others.  We already instead document that
people should instead use `ValueParser` for this case.

In removing this, we remove points of confusion at how the different
multiple values and delimited value calls interact with each other.  I
know I would set `require_value_delimiter(true).multiple_values(true)`
when it turns out all I needed was `value_delimiter(',')`.

This also reduces the API surface area which makes it easier to discover
what features we do provide.

While this isn't big, this is also yet another small step towards
reducing binary size and compile times.
2022-08-03 21:26:36 -05:00
Ed Page
6b3a5bde6d fix(parser)!: Split on value delimiter after validating num_args
This will allow `num_args(0..=1).value_delimiter(',')` to work properly.

This hacks in support for `require_value_delimiter` until we can remove
it.

This no longer recognzes value terminators in delimited lists.

It looks like there is a bug with recognizing value terminators in
positionals arguments.  We'll need to dig into that more.
2022-08-04 00:14:41 -05:00
Ed Page
03f747ba8b fix(parser)!: Only apply num_args to user values 2022-08-03 17:41:42 -05:00
Ed Page
6dddf119ce fix!: num_args controls user args rather than parsed values
This mostly impacts use of delimiters.
2022-08-03 14:45:52 -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
0664c6db37 fix!: Remove Arg::use_value_delimiter in favor of Arg::value_delimiter 2022-08-03 11:15:29 -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
9037e93c72 docs: Update changelog 2022-07-29 20:55:02 -05:00
Ed Page
81bc351cfc fix(help): Show when a flag 'ArgAction::Count's 2022-07-29 09:56:26 -05:00
Ed Page
30f5b11d06 fix!: Replaced min_values (tota) with number_of_values (per occurrence) 2022-07-28 21:40:40 -05:00
Ed Page
ccf35ff70c fix!: Replace min_values (total) with number_of_values (per occurrence) 2022-07-28 17:13:41 -05:00
Ed Page
ab8ef46663 fix: arg!(--long [value]) to per occurrence values
Before we did 0..=1 across all occurrences when what we really wanted
was 0..=1 per occurrence.  This makes it compatible with
`ArgAction::Append`.
2022-07-28 16:52:30 -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
b4dfdcea15 fix!: Change number_of_values to be per occurrence 2022-07-28 16:52:16 -05:00
Ed Page
8e20782bfd fix(parser): Rely on default_missing_value for flag actions
In the short term, this just provides a back door to custom actions.
Longer term, we can explore a `SetConst` action that relies on this
behavior.  Really, `SetTrue` and `SetFalse` are shortcuts for such an
action but shortcuts can be helpful for usability.

Apparently, this also reduced `.text` size by 1k
2022-07-28 15:43:08 -05:00
Ed Page
355a8ff90c fix!: number_of_values doesn't always imply multiple_values(true)
With `number_of_values` being per-occurrence now, its doesn't make sense
for `number_of_values(0)` to set `takes_value(true)` or for
`number_of_values(1)` to set `multiple_values(true)`.

In addition, an assert is made if the user works around this
2022-07-28 14:40:58 -05:00
Ed Page
67adc4acf9 fix(parser)!: Apply default_missing_value per occurrence
This both simplifies the code and the model we present to the user,
making more sense.

There is room for further exploration of tying flag actions into this.
2022-07-27 20:23:58 -05:00
Ed Page
8ea1e2d4d3 fix!: Use value parsers for external subcommands
This changes the default type as well to encourage preserving the full
information for shelling out.  If people need UTF-8, then they can
change the value parser.

Fixes #3733
2022-07-25 14:31:56 -05:00
Ed Page
475a0fc0a2 fix!: Remove PartialEq from Command
This gives us more implementation flexibility
2022-07-25 13:52:13 -05:00
Ed Page
13e672fb90 fix(assert)!: Prevent repeated subcommand names
Fixes #3888
2022-07-25 13:46:18 -05:00
Ed Page
9fb9f563ad docs: Update changelog 2022-07-25 13:31:17 -05:00
Ed Page
ec38212dcb fix(assert)!: Disallow self-overrides
This will make it easier to drop support for multiple occurrences
2022-07-25 12:46:16 -05:00
Ed Page
5a8e2046af fix(assert)!: Ensure overrides_with IDs are valid 2022-07-25 12:26:32 -05:00
Ed Page
dad2492de0 docs: Note change in derive behavior 2022-07-23 21:24:11 -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
11076a5c70 fix(help)!: Make DeriveDisplayOrder the default, removing it
Force sorting with `next_display_order(None)`

Fixes #2808
2022-07-22 15:52:03 -05:00
Ed Page
389ff4ff21 fix(help): Subcommand display order respects Command::next_display_order
Previous behavior:
- They'd be sorted by default
- They'd derive display order if `DeriveDisplayOrder` was set
  - This could be set recursively
- The initial display order value for subcommands was 0

New behavior:
- Sorted order is derived by default
- Sorting is turned on by `cmd.next_display_order(None)`
  - This is not recursive, it must be set on each level
- The display order incrementing is mixed with arguments
  - This does make it slightly more difficult to predict
2022-07-22 15:03:16 -05:00
Ed Page
36dcb05d96 fix!: Change arg! to use ArgAction
Fixes #3795
2022-07-22 13:24:40 -05:00
Ed Page
b77ed545ac fix(env)!: Parse help/version like normal
Fixes #3776
2022-07-22 13:12:12 -05:00
Ed Page
8b064cfee9 fix(derive): Move off of SubcommandRequiredElseHelp
This also let us remove the deprecated attribute

Fixes #3280
2022-07-22 12:33:31 -05:00
Ed Page
0d459128d7 fix(error)!: Merge UnrecognizedSubcommand into InvalidSubcommand
Fixes #3676
2022-07-22 12:12:35 -05:00
Ed Page
a842bd64a0 fix!: Use display_name rather than bin_name in version output 2022-07-22 11:40:30 -05:00
Ed Page
01a3ea425f fix!: Remove unstable-v4 feature gate 2022-07-22 11:34:06 -05:00
Ed Page
16b0362807 fix(error):! Merge EmptyValue into InvalidValue
There isn't a reason to programmatically differentiate them so this
merges them simplify programamtic cases and to hopefully reduce binary
size.
2022-07-22 09:06:01 -05:00
Ed Page
d40e42a9ca chore: Release 2022-07-20 20:13:29 -05:00
Ed Page
88b9406c1b docs: Update changelog 2022-07-20 20:13:20 -05:00
Ed Page
e6b8b4b607 chore: Release 2022-07-19 14:41:47 -05:00
Ed Page
fcd7cae81f docs: Update changelog 2022-07-19 14:39:36 -05:00
Ed Page
a8a7a61f56 chore: Release 2022-07-14 09:38:54 -05:00
Ed Page
ed8837f2cc docs: Update changelog 2022-07-14 09:38:47 -05:00
Ed Page
2df0732df4 chore: Release 2022-07-13 09:08:35 -05:00
Ed Page
1c2242251b docs: Update changelog 2022-07-13 09:08:21 -05:00
Ed Page
9b6321a1f0 chore: Release 2022-07-11 21:48:07 -05:00
Ed Page
096db791bf docs: Update changelog 2022-07-11 21:46:05 -05:00
Ed Page
6614ffa6c8 chore: Release 2022-06-30 08:25:54 -05:00
Ed Page
a67746ecbe docs: Update changelog 2022-06-30 08:25:46 -05:00
Ed Page
b4a1362486 chore: Release 2022-06-28 08:04:18 -05:00
Ed Page
3e80393e43 docs: Update changelog 2022-06-28 08:03:17 -05:00
Ed Page
3823df9bbe chore: Release 2022-06-21 09:32:04 -05:00
Ed Page
8a659bc2b4 docs: Update changelog 2022-06-21 09:31:11 -05:00
Ed Page
a7698e9a1d chore: Release 2022-06-15 11:50:16 -05:00
Ed Page
be2a2c050a docs: Update changelog 2022-06-15 11:50:02 -05:00
Ed Page
20358ff295 chore: Release 2022-06-14 15:01:42 -05:00
Ed Page
241a6fcfbc docs: Update changelog 2022-06-14 15:01:19 -05:00
Ed Page
63a17a40ad chore: Release 2022-06-14 11:19:59 -05:00
Ed Page
d290f11b8d docs: Update changelog 2022-06-14 11:19:23 -05:00
Ed Page
b541f2c880 docs(change): Note debug/release assert change 2022-06-14 08:48:36 -05:00
Ed Page
c510c9da19 docs: Put compatibility first in changelog 2022-06-14 08:47:10 -05:00
Ed Page
478609a937 docs: Move item to correct release section 2022-06-14 07:07:10 -05:00
Ed Page
7836beda05 chore: Release 2022-06-14 07:02:40 -05:00
Ed Page
ea09f67666 docs: Go into more details on derive deprecation 2022-06-14 07:01:42 -05:00
Ed Page
a770000e55 docs: Update changelog 2022-06-14 06:49:27 -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
1d053e9b32 docs: Update changelog 2022-06-13 07:48:58 -05:00
Ed Page
97f8041229 fix(assert): Add missing track_caller attributes 2022-06-13 07:04:59 -05:00
Ed Page
9caec5a52d fix(parser): Deprecate ArgMatches::is_present 2022-06-10 14:21:25 -05:00
Ed Page
9b7813558c feat(parser): Provide updated version if 'is_present'
- This matches the more container-like naming we are aiming for
- This provides an opportunity to warn people about moving away from
  `ArgAction::IncOcccurrences` for flags, like the deprecation for
  `ArgMatches::occurrences_of` to help people migrate in preparation for
  clap 4 (rather than having the behavior change subtly in a way only
  caught by thorough tests)

In addition, I feel `contains_id` has less ambiguous meaning than
`is_present`.
2022-06-10 10:16:44 -05:00
Ed Page
31b22d1a51 perf(parser): Take up less memory with ArgAction::Count
Someone should not reasonably expect a coun flag to go up to billions,
millions, or even thousands.  255 should be sufficient for anyone,
right?

The original type was selected to be consistent with
`ArgMatches::occurrences_of` but that is also used for tracking how
many values appear which can be large with `xargs`.

I'm still conflicted on what the "right type" is an wish we could
support any numeric type.  When I did a search on github though, every
case was for debug/quiet flags and only supported 2-3 occurrences,
making a `u8` overkill.

This came out of a discussion on #3792
2022-06-09 11:09:38 -05:00
Ed Page
cb86785c7f docs: Update changelog 2022-06-09 10:47:08 -05:00
Ed Page
588c46b6c6 docs: Update changelog 2022-06-08 15:04:53 -05:00
Ed Page
524e36cf1a chore: Release 2022-05-10 15:29:16 -05:00
Ed Page
6635237037 docs: Update changelog 2022-05-10 15:28:50 -05:00
Ed Page
55e791e80e chore: Release 2022-05-06 11:57:48 -05:00
Ed Page
ed0c01993c docs: Update changelog 2022-05-06 11:57:39 -05:00
Ed Page
17b930c203 chore: Release 2022-05-05 21:04:09 -05:00
Ed Page
e74864994a docs: Update changelog 2022-05-05 20:55:44 -05:00
Ed Page
0240ec5493 chore: Release 2022-05-02 13:02:10 -05:00
Ed Page
5543315d3b docs: Update chaneglog 2022-05-02 13:02:03 -05:00
Ed Page
5e02ac1c19 chore: Release 2022-04-30 20:21:33 -05:00
Ed Page
f7b00adacf docs: Update chaneglog 2022-04-30 20:21:22 -05:00
Ed Page
b01256be36 chore: Release 2022-04-30 06:36:33 -05:00
Ed Page
09d21f4005 docs: Update changelog 2022-04-30 06:35:38 -05:00
Ed Page
0a1cfe3557 docs(changelog): Start v4 section 2022-04-29 08:21:23 -05:00
Ed Page
d805c6031d chore: Release 2022-04-22 06:52:05 -05:00
Ed Page
d09aec2c14 docs: Update changelog 2022-04-22 06:51:59 -05:00
Ed Page
a46ee83224 chore: Release 2022-04-21 20:08:49 -05:00
Ed Page
62e9d2dfe1 docs: Update changelog 2022-04-21 20:08:35 -05:00
Ed Page
0194568b03 chore: Release 2022-04-19 10:31:52 -05:00
Ed Page
62b1e4874a docs: Update changelog 2022-04-19 10:28:28 -05:00
Ed Page
7598c000f9 chore: Release 2022-04-15 14:39:14 -05:00
Ed Page
d05c5dac41 docs: Update changelog 2022-04-15 14:38:58 -05:00
Linda_pp
4626523ca6
docs: Remove unnecessary backtick in changelog 2022-04-08 13:23:24 +09:00
Ed Page
08f74046dc chore: Release 2022-04-01 09:15:32 -05:00
Ed Page
6aa40ad2cb docs: Update changelog 2022-04-01 09:15:18 -05:00
Ed Page
c75d2642ef chore: Release 2022-03-31 12:22:40 -05:00
Ed Page
b774370565 docs: Update changelog 2022-03-31 12:22:13 -05:00
Ed Page
e702f42e5e chore: Release 2022-03-07 10:40:48 -06:00
Ed Page
591a48ff64 docs: Update changelog 2022-03-07 10:40:30 -06:00
Ed Page
e937955efb chore: Release 2022-03-02 09:49:11 -06:00
Ed Page
3ed151d1b3 docs: Update changelog 2022-03-02 09:49:04 -06:00
Ed Page
1e286f3dc2 chore: Release 2022-03-02 09:20:00 -06:00
Ed Page
e0280ca20e docs: Update changelog 2022-03-02 09:19:04 -06:00
Ed Page
63fa59a251 chore: Release 2022-02-28 10:03:45 -06:00
Ed Page
d87dd9005c docs: Update changelog 2022-02-28 10:03:30 -06:00
Ed Page
20dc6673bc chore: Release 2022-02-23 09:39:40 -06:00
Ed Page
2f9cae8cb4 docs: Update changelog 2022-02-23 09:38:44 -06:00
Ed Page
655c3f0b9f chore: Release 2022-02-21 07:50:28 -06:00
Ed Page
5b26c93ddc docs: Update changelog 2022-02-21 07:50:20 -06:00
Vasili Novikov
7a315afc1a
Fix CHANGELOG for structopt migration 2022-02-17 11:18:15 +01:00
Ed Page
e6729f96c3 chore: Release 2022-02-16 11:59:45 -06:00
Ed Page
92d100279f docs(changelog): Add missing deprecation 2022-02-15 11:28:59 -06:00
Ed Page
94c7775a30 docs: Update changelogs 2022-02-15 10:49:00 -06:00
Ed Page
341b12874d docs(faq): Raise visibility of migration guide
Part of #3422
2022-02-08 17:31:16 -06:00
Ed Page
dc035de409 chore: Release 2022-02-01 16:11:53 -06:00
Ed Page
6fa8113168 docs: Update changelog 2022-02-01 16:10:44 -06:00
Ed Page
d2109b3969 chore: Release 2022-01-26 15:54:12 -06:00
Ed Page
f5ae5714bc docs: Update changelog 2022-01-26 15:53:25 -06:00
Ed Page
ea7699c11f chore: Release 2022-01-24 15:34:27 -06:00
Ed Page
d09188a7ce docs: Update changelog 2022-01-24 15:33:12 -06: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
5877f884f1 chore: Release 2022-01-18 14:59:58 -06:00
Ed Page
8cfa3567ef docs: Update changelog 2022-01-18 14:59:48 -06:00
Ed Page
4b60440d91 docs: Note case in #3309 2022-01-18 10:30:51 -06:00
Ed Page
bd1bf66279 chore: Release 2022-01-17 20:34:09 -06:00
Ed Page
4e51f9b0ef docs: Update changelog 2022-01-17 20:33:52 -06:00
Ed Page
ccbbba8908 chore: Release 2022-01-17 09:37:45 -06:00
Ed Page
6817a9cab2 docs: Update changelog 2022-01-17 09:37:22 -06: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
811fd6a04a chore: Release 2022-01-10 16:16:18 -06:00
Ed Page
29cecfaa5d docs: Update changelog 2022-01-10 16:13:50 -06:00
Ed Page
ef823bbeaf chore: Release 2022-01-05 16:28:24 -06:00
Ed Page
0238a579e1 docs: Update changelog 2022-01-05 16:27:11 -06:00
Ed Page
a61ad342cf docs(changelog): Call out more breaking changes 2022-01-05 10:28:42 -06:00
Ed Page
4ea1965789 chore: Release 2022-01-04 13:07:10 -06:00
Ed Page
c92b91671f docs: Update changelog 2022-01-04 13:07:01 -06:00
Ed Page
9daefba196 chore: Release 2022-01-04 11:42:50 -06:00
Ed Page
6522eb1194 docs: Update changelog 2022-01-04 11:42:35 -06:00
Ed Page
d9906eb150 chore: Release 2022-01-04 09:49:41 -06:00
Ed Page
8830afb6df docs: Update changeog 2022-01-04 09:48:50 -06:00
Ed Page
d392b88bd5 chore: Release 2022-01-03 12:12:28 -06:00
Ed Page
1a19d48765 docs: Update changelog 2022-01-03 12:11:11 -06:00
Ed Page
c01ebbac17 chore: Release 2021-12-31 14:35:02 -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
Ed Page
e5fbdc9b95 Revert "Remove {n} support"
This reverts commit 333b993481.

PR #1810's motivation was effectively "this is redundant with `\n`".
That is a fine motivation.  Unfortunately, we don't have a way to force
a hard break in `clap_derive`.  #2389 should help with this eventually
but we shouldn't hold up 3.0 to get that ready.  So in the mean time, we
are restoring `{n}`.

We have #3230 for tracking the re-removal of it.
2021-12-30 11:44:45 -06:00
Ed Page
3499b6b4b6 docs(changelog): Fix typo 2021-12-23 16:07:29 -06:00
Ed Page
5643dddf3e docs(tutorial): Encourage App::debug_assert 2021-12-23 08:41:52 -06:00
Ed Page
3ae0132f8c docs(changelog): Link out for newline change 2021-12-20 08:38:55 -06:00
Ed Page
95198c95f3 docs: Update changelog 2021-12-15 11:02:12 -06:00
Ed Page
7c10b5a9b4 fix(derive): Treat default_value_os like default_value
The test went from panicing to not-panicing

Fixes #3031
2021-12-13 16:25:49 -06:00
Ed Page
f83ead6a8b docs(change): Update link 2021-12-08 21:03:27 -06:00
Ed Page
ee2d70f8ef docs(change): Fix formatting 2021-12-08 21:01:41 -06:00
Ed Page
b13d66e2d1 docs(change): Fix tag links 2021-12-08 11:49:17 -06:00
Ed Page
90de88e1a3 docs(change): Fix link 2021-12-08 11:48:31 -06:00
Ed Page
b2dc03ec9d docs(change): More consistent formatting 2021-12-08 11:47:39 -06:00
Ed Page
cca6adeedc docs(change): Fix links 2021-12-08 11:45:45 -06:00
Ed Page
5a76a135b2 docs(change): Add v2 changelog
This hasn't been cherry-picked in a while
2021-12-08 11:42:42 -06:00
Ed Page
3fe462c099 docs: Add special note 2021-12-08 11:21:47 -06:00
Ed Page
e5997c1001 docs: Clarify deprecations 2021-12-08 11:14:47 -06:00
Ed Page
4a5d52350e docs: Update old repo location 2021-12-07 08:14:41 -06:00
Ed Page
7dfd1f2e6b docs: Encourage CLI testing 2021-12-06 14:58:56 -06:00
Ed Page
f18f3559e2 docs: Fix example test code 2021-12-06 14:56:45 -06:00
Ed Page
b2836c07a7 fix: Gracefully handle empty authors 2021-12-06 11:30:26 -06:00
Ed Page
4830c75ada docs: Update changelog 2021-12-04 12:07:37 -06:00
Ed Page
951d1fc5c8 doc: Call out release highlights 2021-12-03 20:44:50 -06:00
Ed Page
d2af931c3d doc: Write up migration guide 2021-12-03 20:44:37 -06:00
Ed Page
0cd16c34fc feat: App::debug_assert test helper
This will especially be important for users migrating from clap2 so they
can catch problems earlier in the process.
2021-12-03 14:12:03 -06:00
Ed Page
888c27048d docs: Update changelog 2021-12-02 20:26:21 -06:00
Ed Page
75d417851b docs: Clean up 3.0 changelog 2021-12-02 16:07:43 -06:00
Ed Page
23b988e064 docs: Parent SubcommandPrecedenceOverArg under AppSettings
We have it marked as an `ArgSettings` when it is an `AppSettings`.
2021-11-15 10:27:30 -06:00
rhysd
012f318c97 feat(doc): Fix many typos in docs, comments and codes found by typos-cli 2021-10-19 10:38:22 +09:00
Pavan Kumar Sunkara
585e995811 Release 3.0.0-beta.5 2021-10-17 17:01:18 +01:00
Ed Page
6dd9d467ce fix(help)!: Consoldiate color settings
A lot of users expected `color` feature flag and `ColorAuto` etc to
control all colors.  Having this extra flag around is easy to miss and
adds to our overall settings bloat, making it harder to find settings
people want.

This completely removes it, rather than make it deprecated like
functions in #2617, because there is extra work to mark things
deprecated as Settings and we should decide on our strategy first before
investing time in addressing that issue.

Fixes #2806
2021-10-11 09:01:13 -05:00
bors[bot]
e8ec11e57f
Merge #2837
2837: fix: Gate App::replace r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-09 16:27:41 +00:00
Ed Page
dfbeb71077 fix: Gate App::replace
We are concerned about the level of polish of this feature and are
unsure enough about its future, we've decided to gate it to unblock the
v3 release.
2021-10-09 10:49:10 -05:00
Kevin K
7b45695878
breaking(DisableVersionForSubcommands): removed
This commit removes `AppSettings::DisableVersionForSubcommand` as it's
now a moot setting with clap's default functionality of not building a
version flag unless there actually exists version information.

`clap_up` must still be changed to remove this variant instead of the
current configuration to simply rename the variant.
2021-10-09 11:12:50 -04:00
Ed Page
2bbe9123ee fix!: Generalize unicode feature
This flag was added in v3.  This will allow us to put more related
functionality behind it.

BREAKING CHANGE: `unicode_help` was renamed to `unicode`.
2021-10-09 06:27:28 -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
52be134949 Release 3.0.0-beta.4
clap@3.0.0-beta.4
clap_derive@3.0.0-beta.4
clap_generate@3.0.0-beta.4

Generated by cargo-workspaces
2021-08-14 23:40:49 +01:00
Pavan Kumar Sunkara
73b28fb104 Release 3.0.0-beta.3
clap@3.0.0-beta.3
clap_derive@3.0.0-beta.3
clap_generate@3.0.0-beta.3

Generated by cargo-workspaces
2021-08-14 23:01:13 +01:00
Pavan Kumar Sunkara
a9b86ecefc Update changelog 2021-08-14 22:46:49 +01:00
Ed Page
241d183b9c Bump MSRV to 1.54.0
- This makes it so `doc` compiles on stable

Fixes #2618
2021-07-30 10:19:21 +01:00
Pavan Kumar Sunkara
3f94d17c71 Removed Arg::multiple 2021-06-16 07:17:11 +01:00
Pavan Kumar Sunkara
6a395d3208 ArgMacthes::is_present should not deal with subcommands at all, fixes #2494 2021-05-26 00:40:38 +01:00
Reagan McFarland
b184dc001b setting: SubcommandHelpShowsLongForm implemented
Refactoring and better test cases

Refactored SubcommandHelpShowsLongForm to
UseLongFormatForHelpSubcommand.
Tests and docuemntation examples use about and long_about instead of
(before/after)_help.

Removed commented out tests

Linting: Fix trailing new line

Updated change log, refactored tests and doc str

Reordered items in the Changelog
New test added and old tests removed that were redundant
Doc string for AppSettings::UseLongFormatForHelpSubcommand fixed
2021-04-11 14:31:40 -04:00