Commit graph

2354 commits

Author SHA1 Message Date
Ed Page
639f9e8849 refactor(parser): Pull out long-help determination
This isn't a parser policy but command-level policy.
2022-04-21 15:49:02 -05:00
Ed Page
a484f622de fix(validate): Overrides always ignore required
Before, if two arguments were required *and* overrode each other, then
`cmd --opt=1 --other=2` succeded but `cmd --other=2` failed despite
ignoring `--opt=1`.  Requiring `--opt=1` to be present but unavailable
doesn't help anyone and makes the behavior less predictable.

Now both commands will have the same behavior.
2022-04-21 15:23:05 -05:00
Ed Page
de89c050c9 fix(validate): Consistent conflict behavior
We had two different implementations of conflicts
- Validating conflicts
- Allowing conflicts to override `required`
  - Missing members of a group conflicting with each other
  - Missing symmetric conflicts (A conflicts with B so B conflicts with
    A)

This consolidates their implementations which should fix overriding of
`required`.
2022-04-21 15:03:56 -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
Ed Page
7598c000f9 chore: Release 2022-04-15 14:39:14 -05:00
Ed Page
7849c35a3e
Merge pull request #3635 from epage/port
feat: Expose clap_lex
2022-04-15 14:00:28 -05:00
Ed Page
15d8b3b0cd style: Make clippy happy 2022-04-15 13:49:02 -05:00
Ed Page
e46cf659d6 fix(lex): Provide all dat with ParsedArg::to_value 2022-04-15 12:40:05 -05:00
Ed Page
96dc6daa9e feat(lex): Pull out clap_lex 2022-04-15 10:55:37 -05:00
Ed Page
6291289c0f fix(lex): Make long args more convinient 2022-04-15 10:55:34 -05:00
Ed Page
1247a955cf docs(lex): Specify how it all works 2022-04-15 10:55:28 -05:00
Ed Page
6148d681f4 refactor(lex): Clarify side effects 2022-04-15 10:55:25 -05:00
Ed Page
fd16ee9474 refactor(lex): Port to expanded lexer 2022-04-15 10:55:19 -05:00
Ed Page
6e05b8075b refactor(lex): Expand lexer design
In considering the design for this, we want:
- Ability to modify the argment list while maintaining the `Cursor` for
  replacements
- Allow picking up subcommand parsing in the middle of short flags
- Ability to peek at the next item to determine if we want to treat it
  as a flag or as a value
- Ability to detect started short and long arguments for completions

Longer term, we also want to consider:
- Allowing users to customize the lexer to support different syntaxes
2022-04-15 10:55:12 -05:00
Ed Page
c58928b6bd refactor(lex): Track replacements as str
The lexer will soon return `RawOsStr` and it'll cost to turn that into
an `OsStr`.  However, it caches a `str`, so let's just use that.
2022-04-15 10:55:08 -05:00
Ed Page
f66d8abebd refactor(lex): Experiment with an alt 'previous'
Since we'll need `skip`, it made me wonder how to name `skip` and
`previous` to fit together, so I decided to play with `seek`.  Its
probably over kill but wondering if its better.
2022-04-15 10:55:05 -05:00
Ed Page
3ebf61e28d refactor(lex): Narrow focus for lexer
Before, we had a generic `next` that provided the next item and peeked
at all remaining items.  This was to work around the borrow checker for
modifying the position while accessing args.

We've now split `Input` into `RawArgs` and `ArgsCursor` so we don't have
overlapping borrows.  This made it so we can split `next` into `next`,
`peek`, and `remaining`.
2022-04-15 10:55:00 -05:00
Ed Page
0000d506ed refactor(lex): Remove unused bound 2022-04-15 10:54:50 -05:00
Ed Page
65120784f5 refactor(lex): Split out input cursor 2022-04-15 10:54:43 -05:00
Chloe-Woahie
87c87565af docs: Fixed documentation typos 2022-04-10 12:43:09 -04:00
Ed Page
a3b628998d docs: Don't encourage index
Its extra maintenance and more likely to cause annoyances.

Fixes #3608
2022-04-04 08:52:20 -05:00
Ed Page
08f74046dc chore: Release 2022-04-01 09:15:32 -05:00
Kevin Moonen
17fed36da3 fix: Bring forward Debug impls from v2 2022-03-31 22:45:37 -05:00
Ed Page
c75d2642ef chore: Release 2022-03-31 12:22:40 -05:00
Samuel Tardieu
ef3c2c73d5 docs: arg! macro uses double quotes for help string 2022-03-25 11:00:47 +01:00
Grachev Mikhail
02d4d6b137
chore: fix typo 2022-03-14 14:45:42 +03:00
Thayne McCombs
2b86726879 docs: Document grouped_values_of
Relates to #2924
2022-03-10 00:53:46 -07:00
Ed Page
e702f42e5e chore: Release 2022-03-07 10:40:48 -06:00
plaflamme
b6df23dc14
fix: Multiple defaults combined with ArgEnum 2022-03-06 23:10:16 -05:00
Ed Page
c6d456f608 fix(builder): Tell users cargo feature is needed
This will help in cases like #3530
2022-03-03 12:43:10 -06:00
Ed Page
e937955efb chore: Release 2022-03-02 09:49:11 -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
63fa59a251 chore: Release 2022-02-28 10:03:45 -06:00
Ed Page
3f2a37088b fix(assert): Validate delimited defaults
Fixes #3514
2022-02-28 09:21:44 -06:00
Ed Page
20dc6673bc chore: Release 2022-02-23 09:39:40 -06:00
Ed Page
655c3f0b9f chore: Release 2022-02-21 07:50:28 -06:00
Ed Page
006a161e39
Merge pull request #3492 from kornelski/trac
More track_caller
2022-02-21 07:48:19 -06:00
Ed Page
fa24b9f173 docs: Tell people to use latest API
Fixes #3478
2022-02-16 16:27:44 -06:00
Kornel
2437051eff More track_caller 2022-02-16 18:40:20 +00:00
Ed Page
e6729f96c3 chore: Release 2022-02-16 11:59:45 -06:00
Ed Page
3dd3993682 docs(builder): Add ToC to Command, Arg 2022-02-15 11:40:58 -06:00
Ed Page
94e2727bd0 docs(builder): Clarify command-wide 2022-02-15 11:30:26 -06:00
Ed Page
15c7abb196 docs(parser): Fix ArgMatches::value_source documentation 2022-02-15 11:23:40 -06:00
Ed Page
b171802265 docs: Ensure IntoApp is visible 2022-02-15 11:16:22 -06:00
Ed Page
976f3d500a
Merge pull request #3473 from epage/derive
fix: Change `IntoApp::into_app` to `CommandFactory::command`
2022-02-15 09:33:44 -06:00
Ed Page
360c4d6b8a docs: Update to new command! macro 2022-02-15 08:54:59 -06:00
Ed Page
65b9c88b3c fix: Update app_from_crate for App rename
Instead of just renaming it, I reconsidered what the API should look
like.  A custom separator for author does not make sense positionally
but accepting a name, and defaulting it, does fit with what someone
would expect.

I removed the `_from_crate` suffix because it doesn't seem necessary.
We don't have this kind of naming for the derive.  I feel it cleans
things up this way.
2022-02-15 08:39:07 -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