Commit graph

2384 commits

Author SHA1 Message Date
Ed Page
ce727f1951 fix(error): Render actual usage for unrecognized subcommands
For some reason this code path diverged and manually constructed a
usage, not following any of our patterns for doing so.
2022-05-02 09:25:44 -05:00
Ed Page
5cd1a4070b fix(multicall): Show subcommands are required 2022-05-02 09:13:44 -05:00
Ed Page
414ae57a2a fix(multicall): Improve bad multicall binary error
By removing all arguments, we've switched from an "unrecognized
argument" error to a "unrecognized subcommand" error.  While the wording
has room for improvement, its at least progress on #2862.
2022-05-02 09:12:12 -05:00
Ed Page
5e02ac1c19 chore: Release 2022-04-30 20:21:33 -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
c6849e2ebd fix(debug): Moe detail 2022-04-30 19:07:42 -05:00
Ed Page
b01256be36 chore: Release 2022-04-30 06:36:33 -05:00
Ed Page
8df20478a4 style: Make clippy happy 2022-04-29 20:26:59 -05:00
Ed Page
ccf8634c19 fix(help): Provide correct context for help subcmd errors 2022-04-29 20:25:05 -05:00
Ed Page
1452c1e42b fix(help): Help subcommands usage includes requires arguments 2022-04-29 20:16:19 -05:00
Ed Page
37ebb71806 fix(help): write_help usage includes required arguments 2022-04-29 20:15:54 -05:00
Ed Page
515a37dba1 fix(debug): Improve debug output of bin building 2022-04-29 16:18:30 -05:00
Ed Page
bcde91b101 fix(debug): Update Command's debug statements 2022-04-29 16:07:47 -05:00
Ed Page
ba0301d9b4 refactor(builder): Group related build functions 2022-04-29 09:36:28 -05:00
Ed Page
7113e46388 fix(builder): Deprecate public Command::_build_bin_names 2022-04-29 09:21:42 -05:00
Ed Page
397e8443f9 refactor(builder): Consistently use internal function 2022-04-29 09:16:20 -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
d4ddc5f6d6 clap(debug): More conflict details 2022-04-27 12:38:12 -05:00
Ed Page
f083ef92c5 fix(lex)!: Don't do prefix matching by default
Finding this a pain in `clap_complete`; not offering the benefits I
expected.
2022-04-27 12:38:12 -05:00
Ed Page
5ae9c75324 fix(clap): Allow disabling color with debug 2022-04-22 12:32:58 -05:00
Ed Page
1e2471649e test(output): Ensure correct streams
This is to prevent #3648 from happening again
2022-04-22 10:56:47 -05:00
Ed Page
4e20af3498 refactor(parser): Reduce visibility of parser fields 2022-04-22 07:03:07 -05:00
Ed Page
d805c6031d chore: Release 2022-04-22 06:52:05 -05:00
Arlo Siemsen
854017b478 fix: Mixup between stderr and stdout introduced in v3.1.11 2022-04-22 02:09:22 -05:00
Ed Page
a46ee83224 chore: Release 2022-04-21 20:08:49 -05:00
Ed Page
9d523012fe refactor(validator): Decouple parser 2022-04-21 16:31:04 -05:00
Ed Page
6229e78bc6 refactor(parser): Parser is solely responsible for populating ArgMatches 2022-04-21 16:24:10 -05:00
Ed Page
02ffd59830 refactor(help): Move help writing down a layer 2022-04-21 16:14:11 -05:00
Ed Page
ebeade91bf refactor(help): Consolidate help errors 2022-04-21 16:12:01 -05:00
Ed Page
6a9a5d05b0 refactor(help): Make bool's meaning clearer 2022-04-21 16:01:47 -05:00
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