Commit graph

149 commits

Author SHA1 Message Date
Ed Page
2c64f920e2 docs(man): Remove version from setup steps 2023-01-27 11:38:33 -06:00
Benjamin Gilbert
3755c56dcf fix(mangen): Avoid spurious value for derive arg
derive arguments like this:

    #[arg(long)]
    pub flag: bool,

were producing option descriptions like this:

    --flag=FLAG

FLAG is spurious.  It turns out that derive always sets a value name, for
simplicity, even when there are no arguments.  Check for this case.

Fixes #4443.
2023-01-16 12:04:43 -05:00
Ed Page
34d856b449 chore: Release 2023-01-13 09:27:31 -06:00
Ed Page
889ca7a537 chore: Bump versions for 4.1 2023-01-13 09:24:37 -06:00
Ed Page
a41ca2edb0 docs: Update changelog 2023-01-13 07:13:28 -06:00
Enrico Guiraud
84314614fb
docs: prefer ok_or to ok_or_else in README example
As suggested by clippy when using the example code.
2023-01-11 16:41:08 -06:00
Ed Page
fa02111092 chore: Switch to workspace inheritance 2023-01-09 12:35:54 -06:00
Ed Page
f25fe5b3e0 chore: Bump MSRV to 1.64.0 2023-01-09 12:29:41 -06:00
Ed Page
36bc641648 fix(help): Remove extraneous text from built-ins
This is an intermediate solution for #4408.  As there were no agreeed
upon goals, I went with what I felt read well and that I saw commonly
used on non-clap commands.

- "information" isn't really a necessary word.
- I originally favored `Print this help` but realied that doesn't read
  correctly in completions.
- Besides being shorter, the reason for the flipped short/long hint is
  it gives people the context they need for scanning, emphasizing
  "summary" and "more".

Fixes #4409
2023-01-03 11:02:26 -06:00
Ed Page
0eccd556ac chore: Release 2022-12-22 12:40:15 -06:00
Ed Page
dde22e74ca style: Update for latest clippy 2022-12-22 12:25:33 -06:00
Ed Page
3262016c26 chore: Release 2022-11-24 11:40:15 -06:00
Ed Page
623ccbc152 style: Make clippy happy 2022-11-24 08:05:21 -06:00
Ed Page
27bfcc56a9 chore: Release 2022-10-31 06:54:01 -05:00
Ed Page
c8423ff42d docs(man): Update changelog 2022-10-31 06:52:32 -05:00
Daniel Rivas
7030e9e995 fix: Don't show default values for flags
Also show ellipsis for repeatable arguments.
2022-10-30 18:28:17 +00:00
Ed Page
996636d56f chore: Release 2022-10-18 14:37:53 -05:00
Ed Page
3e23cd102f fix: Require release versions of clap 2022-10-18 14:36:44 -05:00
dependabot[bot]
f0d971562a
chore(deps): bump snapbox from 0.3.3 to 0.4.0
Bumps [snapbox](https://github.com/assert-rs/trycmd) from 0.3.3 to 0.4.0.
- [Release notes](https://github.com/assert-rs/trycmd/releases)
- [Changelog](https://github.com/assert-rs/trycmd/blob/main/CHANGELOG.md)
- [Commits](https://github.com/assert-rs/trycmd/compare/snapbox-v0.3.3...snapbox-v0.4.0)

---
updated-dependencies:
- dependency-name: snapbox
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-01 18:58:27 +00:00
Ed Page
668c021419 chore: Release 2022-09-29 13:09:30 -05:00
Ed Page
9069755919 docs: Update changelog 2022-09-29 13:09:14 -05:00
Ed Page
d24e723bb4
Merge pull request #4255 from anshulrgoyal/master
[clap_mangen]fix: use proper sub-command name in manpages
2022-09-29 13:07:18 -05:00
Anshul Goyal
cdcf9aad34 fix: Add test for subcommand 2022-09-29 23:07:28 +05:30
Ed Page
f6602c573c chore: Release 2022-09-28 14:51:22 -05:00
Ed Page
1e171cfef6 docs: Update changelog 2022-09-28 14:47:24 -05:00
Ed Page
5d9920480c Merge branch 'master' into HEAD 2022-09-28 12:03:37 -05:00
Ed Page
3a74d82376 chore: Release 2022-09-28 12:00:48 -05:00
tahmid-23
e6cd076438 fix(mangen): Respect more hide values 2022-09-27 15:40:56 -04:00
Anshul Goyal
637e7be3a4 fix: Format with rustfmt 2022-09-24 23:45:50 +05:30
Anshul Goyal
6436d19b68 fix: Use proper sub-command name in manpages 2022-09-24 23:38:44 +05:30
Ed Page
16c46b4b3b chore: Release 2022-09-20 16:32:10 -05:00
Ed Page
7a5dad89ff feat(help): Break out help feature flag
This removes auto-generated help, saving about 50 KiB.
2022-09-19 11:54:10 -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
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
6bd4fee69f chore: Update dependencies 2022-09-01 07:09:32 -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
c6155f62d5 feat: Open the door for user styling in the future
This added about 10 KiB to the `.text` which I cannot explain why
2022-08-24 18:17:42 -05:00
Tyler Calder
a55db43758 fix: Add possible vals to man for positional args
Noticed that possible values would not show up for Positional arguments
as well. Decided to add the changes for those as well.
2022-08-23 22:03:37 -06:00
Tyler Calder
069098cfcb fix: Use roff bullet lists for possible_values 2022-08-23 21:54:46 -06:00
Tyler Calder
ec518e4819 fix: Take in account possible values being hidden
This makes sure we take into account the setting that possible args
is hidden
2022-08-23 21:47:17 -06:00
Tyler Calder
6342802f55 fix: Show possible values in generated man file
This adds feature parity for mangen with the standard help output. Users
will now see the list of possible values for value arguments.

One change that was made to make this possible was adding the method
`get_possible_values` to the public API for an arg. I tried to think of
a way to get around this, but because this is the interface that the
help generation uses, and it is part of the crate public interface
I thing adding it as a part of the public API might be for the best.

fixes: #3861
2022-08-23 21:47:17 -06:00
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
Ed Page
5b5f2c1f40 fix!: Track original Ids, rather than a hash
This is a step towards #1041
- `ArgGroup` no longer takes a lifetime
- One less field type needs a lifetime

For now, we are using a more brute force type (`String`) so we can
establish performance base lines.  I was torn on whether to use `&str`
everywhere or make an `IdRef`.  The latter would add a lot of noise that
I'm concerned about, so i left it simple for now.  `IdRef` would help to
communicate the types involved though.

Speaking of communicating types, I'm also torn on whether we should use
`Id` for all strings or if we should have `Id`, `Name`, etc types to
avoid people mixing and matching.

This added 18.7 KB.

Compared to `HEAD~` on `06_rustup`:
- build: 6.23us -> 7.41us
- parse: 8.17us -> 9.36us
- parse_sc: 7.65us -> 9.29us
2022-08-12 15:46:04 -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
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
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
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
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
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
73ea5bc4a9 chore: Release 2022-06-13 09:33:33 -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
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
6e778679cc chore: Release 2022-04-20 08:51:43 -05:00
Ed Page
b7bd298385 docs(man): Update changelog 2022-04-20 08:51:35 -05:00
Orhun Parmaksız
2740be259c
fix(man): show the environment info with separate paragraph (#3631)
This commit updates the man page renderer to use a relative margin
indent for environment variable text instead of appending to the
existing help text.

Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Fixes: #3630
2022-04-20 08:50:11 -05:00
Ed Page
cad55a2de2 chore: Release 2022-04-19 11:50:17 -05:00
Benjamin Gilbert
d50ab883aa fix(man): Explicitly depend on clap 3.1.10
Command.build() is not available in 3.1.9.

Fixes: 8f182067e3 ("feat(clap): Publicly expose `Command::build`")
2022-04-19 12:30:39 -04: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
Ed Page
297b9cf594 chore: Release 2022-04-15 14:05:51 -05:00
Ed Page
b3cbfd0ae0 docs(man): Update changelog 2022-04-15 14:05:29 -05:00
Ed Page
858f184428
Merge pull request #3587 from ducaale/value-name-as-header-positional
Use `Arg::value_name()` as header for positionals in clap_mangen
2022-04-04 09:56:41 -05:00
ducaale
fbfeaabfd1 fix(clap_mangen): Use italic for replaceble args 2022-04-03 13:35:30 +01:00
Ed Page
e91d18ba0e
Merge pull request #3605 from ducaale/synopsis-hidden-flags
Don't include hidden flags in the synopsis section from clap_mangen
2022-04-02 19:59:50 -05:00
ducaale
ddc83bfdc8 test(clap_mangen): Hidden flags in synopsis 2022-04-03 00:28:31 +01:00
ducaale
b3b49855ab fix(clap_mangen): Hide hidden flags in synopsis 2022-04-03 00:11:45 +01:00
ducaale
99d6737521 fix(clap_mangen): Update snapshot tests 2022-04-03 00:03:02 +01:00
ducaale
fbd33891b4 fix(clap_mangen): Use value_names for positionals 2022-03-28 21:22:18 +01:00
ducaale
d55e46f65f docs(mangen): Fix docs for Man::section() 2022-03-26 17:49:34 +00:00
Ed Page
7c86eeb176 test(man): Add snapshot tests 2022-03-07 14:12:59 -06:00
Ed Page
d7a35137e3 chore: Release 2022-02-16 12:01:29 -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
77542a1138 refactor: Reduce visibility on App members
The long term goals are
- Easier refactoring
- Identify needs for reflection API

Shorter term, if I want to rename `App` to `Command` and deprecate
`App`, it will mark all member access as deprecated.  This works around
that.

I gave up in exploring abstractions when it came to `MKeyMap` access.
This can be refined in the future.
2022-02-14 14:17:48 -06:00
Ed Page
4895a32e81 fix: Deprecate SubcommandRequiredElseHelp
Now that we can use `SubcommandRequired |
ArgRequiredElseHelp`, this setting offers little value but requires we
track required subcommands with two different settings.  Deprecating as
the cost is not worth the benefit anymore.

Issue #3280 will see the derive updated
2022-02-11 15:31:25 -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
48686804c7 docs(man): Fix links 2022-02-10 13:54:29 -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
135b15467e chore: Release 2022-02-08 10:28:40 -06:00
Ed Page
1330a46bf0 docs: Update changelog 2022-02-08 10:28:27 -06:00
Ed Page
6cd069ab5d docs: Expand doc comments 2022-02-08 10:10:22 -06:00
Ed Page
c5080f1139 docs(man): Fill our README 2022-02-08 09:59:57 -06:00
Ed Page
86bf680645 fix(man): Rename crate to match style
I have access to the `clap-man` name but we use `clap_*`.  Rather than
people getting mixed up on which is supposed to use, we went with a
different name.
2022-02-07 20:20:01 -06:00