Commit graph

2357 commits

Author SHA1 Message Date
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
Ed Page
c3fec1fa75 fix: Update derive->Command function name
No good solution for transitioning the trate name, unfortnately, since
we can't mark `use`s as deprecated (we can, it just does nothing).

I got rid of the `into` prefix because that implies a `self` parameter
that doesn't exist.
2022-02-14 16:04:10 -06:00
Ed Page
e8010e79a9 refactor: Update app variables to cmd 2022-02-14 15:55:56 -06:00
Ed Page
9a7e6a523d fix: Deprecate App 2022-02-14 15:34:27 -06:00
Ed Page
c4144d7d6c docs: Update App references to Command 2022-02-14 15:33:49 -06:00
Ed Page
524e164c31 fix: Rename App to Command 2022-02-14 15:32:07 -06:00
Ed Page
06b269a85a refactor: Rename Apps file 2022-02-14 15:29:26 -06:00
Ed Page
44d85344a9 refactor: Be consistent in mod visibility 2022-02-14 15:28:38 -06:00
Ed Page
a627778809 refactor: Generalize test file name 2022-02-14 14:42:23 -06:00
Ed Page
3475555de6 fix(help): Use standard alternate syntax for subcommands 2022-02-14 21:18:33 -06:00
Ed Page
9a83ada940 fix(help): Separate subcommand flags 2022-02-14 16:20:33 -06:00
Ed Page
8c5e42e0fb fix(help): Show subcommand flags in same order as usage 2022-02-14 16:20:03 -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
58000253d7 refactor: Clarify role of usage name 2022-02-14 12:52:37 -06:00
Ed Page
235cbb615e refactor: Centralize build logic 2022-02-14 12:52:37 -06:00
Ed Page
3f32030f7f refactor: Delay collecting required
The main goal is to allow centralizing some building logic currently
split between the parser and `App`.  It depends on this logic.

As a side benefit, this allowed us to decouple some operations from `Parser` in `App`.

The main impact I can see is that we'll calculate the required once for
parsing a subcommand and once for validation.
2022-02-14 12:52:37 -06:00
Ed Page
b994789ee6 refactor: Prepare for deferring graph creation 2022-02-14 12:52:37 -06:00
Ed Page
54c2f0df05 refactor: Open door for multiple writes 2022-02-14 12:52:37 -06:00
Ed Page
6886109fa6 refactor: Make use refactor friendly 2022-02-14 12:52:37 -06:00
Ed Page
6c7126b156 docs: Hide items deprecated in 3.0.0
We left them in the docs for a period of time to help people find docs
for code that was still in use.  Balancing that with the need for clean
docs, it seems like 3.1 is an appropriate time to mark them hidden in
the docs.
2022-02-11 18:42:28 -06:00
Ed Page
97e36451cf docs: Update stale references to AppSettings 2022-02-11 15:58:12 -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
e8e469178c fix(validate): Give precedence to ArgRequiredElseHelp 2022-02-11 14:59:52 -06:00
Ed Page
c0fd6753ea refactor(validate): Clarify subcmd check intent 2022-02-11 14:55:57 -06:00
Ed Page
8e5ce6c044 refactor(validate): Drop us to one req check 2022-02-11 14:36:42 -06:00
Ed Page
9824f8d0ba perf(validate): Remove unnecesarry walking of args 2022-02-11 14:27:18 -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
06d43a02da fix(help): Subcommand help looks like --help
Like was said in #2435, this is what people would expect.

While we should note this in a compatibility section in the changelog, I
do not consider this a breaking change since we should be free to adjust
the help output as needed.  We are cautious when people might build up
their own content around it (like #3312) but apps should already handle
this with `--help` so this shouldn't be a major change.

We aren't offering a way for people to disable this, assuming people
won't need to.  Longer term, we are looking at support "Actions" (#3405)
and expect those to help customize the flags.  We'll need something
similar for the `help` subcommand.

Fixes #3440
2022-02-11 12:47:34 -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
de7c81e059 fix(error): Deprecate WaitOnError
Fixes #3439
2022-02-11 09:00:10 -06:00
Ed Page
547665d52a fix(color): Allow overriding previous settings 2022-02-11 09:00:10 -06:00
Ed Page
bdb034b1b5 docs: Clarify app-wide vs command-specific settings 2022-02-11 09:00:10 -06:00
Ed Page
9bd7060089 fix: Deprecate various APIs
- ArgSettings are part of #2717
- Errors are part of #2628
- `help_heading` is part of #1807 and #1553
- Some misc parts are for API consistency
2022-02-10 19:37:47 -06:00
Ed Page
60a8747603 refactor: Flatten directory heirarchy 2022-02-10 11:17:08 -06:00
Ed Page
fb9e4e7c25 refactor: Centraize all debug asserts 2022-02-10 11:10:34 -06:00
Ed Page
b7842c2e11 refactor: Flatten directory heirarchy 2022-02-10 11:07:57 -06:00
Ed Page
727c453322
Merge pull request #3434 from epage/setting
feat: Add `Arg` getters for all settings
2022-02-10 10:37:59 -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
Malloc Voidstar
bd49665bd5
docs: validator takes &str, not String
Explicit link removed as it doesn't appear to be necessary
2022-02-09 21:03:19 -08:00
Ed Page
81092b5aed fix: Detect deeply recursed global args
Fixes #3428
2022-02-09 16:05:27 -06:00
Ed Page
82dfc7d5ea perf: Reduce parse allocations 2022-02-09 15:24:52 -06:00
Ed Page
6c60b79d21 fix(assert): Provide next steps for '-h' conflicts
For now, we are going to provide a better debug assert in this case.
Resolving #3405 is the better long term route.

Fixes #3403
2022-02-08 18:56:14 -06:00
Ed Page
df1d50c367 fix: Easier to debug help flags 2022-02-08 18:51:51 -06:00
Ed Page
12c29526fa fix(parser): Give room for more ValueSources 2022-02-08 15:05:59 -06:00
Ed Page
f42fc89288 fix(parser): Remove an internal-only ValueSource 2022-02-08 15:05:59 -06:00
Ed Page
edda56f072 feat(parser): Expose ValueSource
Fixes #1345
2022-02-08 15:05:51 -06:00
Ed Page
9f41bb3948 fix(assert): Report invalid defaults in debug asserts
This can help people catch them via `App::debug_assert` rather than
waiting until the default is used and validated.

Fixes #3202
2022-02-08 14:41:33 -06:00
Ed Page
b2d1ebef4b fix(help): ArgsRequiredElseHelp should ignore defaults
Fixes #1264
2022-02-08 12:34:19 -06:00
Ed Page
25b8fe8edb Revert "Revert "Revert "Revert "docs: Clarify corner caseses with default values""""
This reverts commit 26bbe606d3.
2022-02-08 12:27:52 -06:00
Ed Page
e87881f91a fix(validate): Limit relationship checks to non-defaults 2022-02-08 12:17:39 -06:00
Ed Page
f59c82bc1d refactor(validate): Clarify intent of code 2022-02-08 11:52:07 -06:00
Ed Page
279e39a858 fix(validate): Only check requires when target is set by user
Unrolling serves two distinct purposes but we muddied them together
- Is `requires` satisfied for validation
- Report what arguments are currently considered required for usage

This was split out of #3020
2022-02-08 11:24:47 -06:00
Ed Page
2b265ea81a fix(validate): Only check if value is set by user
This was split out of #3020
2022-02-08 08:12:39 -06:00
Ed Page
f830bf93b0 refactor(validate): Generalize contains_explicit 2022-02-08 08:11:46 -06:00
Ed Page
3a517b6583 refactor(validate): Centralize all required logic 2022-02-08 07:34:11 -06:00
Ed Page
6ad52f41b3 feat: Allow disabling derive display order
In clap 4.0, we will make `DeriveDisplayOrder` the default and this is
how you'll disable it.

This is part of #2808
2022-02-07 19:19:11 -06:00
Ed Page
5290f82133 feat: Override DeriveDisplayOrder behavior with App::next_display_order
For the derive API, you can only call `next_display_order` when dealing
with a flatten.  Until we offer app attributes on arguments, the user can workaround with
this no-op flattens.

This is a part of #1807
2022-02-07 19:19:11 -06:00
Ed Page
16bf834aa5 refactor: Prepare for overriding derived display order 2022-02-07 19:19:11 -06:00
Ed Page
c00f71ec4a feat: Add App::next_help_heading
This clarifies the intent and prepares for other functions doing the
same, like `next_display_order`.  This will then open us to name
`subcommand_help_heading` and `display_order` similar.

The deprecation is waiting on 3.1.

This is part of #1807 and #1553.
2022-02-07 19:19:01 -06:00
Ed Page
4f50e97f23 docs: Prepare for 3.1 deprecations
Don't want to forget this remaining work
2022-02-07 19:17:09 -06:00
Ed Page
07e4e424ac perf(error): Take arond 5kb off 2022-02-07 14:55:24 -06:00
Ed Page
e3e0a91561 fix(error): Don't overload fields 2022-02-07 14:47:49 -06:00
Ed Page
84416b267c style: Make clippy happy 2022-02-07 13:06:04 -06:00
Ed Page
600d741d65 feat(error: Expose unknown-argument context 2022-02-07 13:03:23 -06:00
Ed Page
6079bae959 perf: Reduce binary size by 11k 2022-02-07 12:35:23 -06:00
Ed Page
3f06e13a85 feat(error: Expose argument-not-found context 2022-02-07 10:58:02 -06:00
Ed Page
a4b044df81 feat(error: Expose unexpected-multiple context 2022-02-07 10:32:42 -06:00
Ed Page
2434f51129 feat(error: Expose wrong-number context 2022-02-04 14:52:31 -06:00
Ed Page
7497dbb6cc feat(error: Expose value-validation context 2022-02-04 14:35:52 -06:00
Ed Page
3d4f31b223 feat(error: Expose too-few context 2022-02-04 14:24:46 -06:00
Ed Page
ee2860e434 feat(error: Expose too-many-values context 2022-02-04 14:10:16 -06:00
Ed Page
2b60c598b7 feat(error: Expose too-many context 2022-02-04 13:53:57 -06:00
Ed Page
03fbb50283 refactor(error): Make room for more values 2022-02-04 13:44:49 -06:00
Ed Page
f7731d1f03 feat(error: Expose invalid-utf8 context 2022-02-04 13:42:36 -06:00
Ed Page
f54bcc85b7 feat(error: Expose missing-subcommand context 2022-02-04 13:18:51 -06:00
Ed Page
9b18f8087c feat(error: Expose missing-required context 2022-02-04 12:45:48 -06:00
Ed Page
71535866b9 feat(error: Expose invalid-subcommand context 2022-02-04 12:23:06 -06:00
Ed Page
5095e5c992 feat(error: Expose unrecognized-subcommand context 2022-02-04 11:15:22 -06:00
Ed Page
1a0d7bac29 feat(error: Expose invalid-value context 2022-02-04 10:24:51 -06:00
Ed Page
04aa6029b8 refactor(error): Generalize kind name 2022-02-04 10:08:51 -06:00
Ed Page
1463f82cf1 feat(error: Expose no equals context 2022-02-04 10:07:14 -06:00
Ed Page
9759f2f1ea refactor(error): Share template across kinds 2022-02-04 10:03:09 -06:00
Ed Page
630e7097fc feat(error: Expose empty value context 2022-02-04 10:01:07 -06:00
Ed Page
0c36fc2073 feat(error): Expose argument conflict context 2022-02-04 09:59:06 -06:00
Ed Page
7029e76545 refactor(error): Prepare for deferring formatting 2022-02-04 09:56:22 -06:00
Ed Page
c002951dc8 refactor(error): Centralize app knowledge 2022-02-04 09:51:34 -06:00
Ed Page
ee63f6cd9b refactor(error): Prepare for optional deferred formatting 2022-02-04 09:45:12 -06:00
Ed Page
af41e8d6b2 refactor(error): Separate try_help concerns 2022-02-04 08:49:55 -06:00
Ed Page
8de99407f9 feat(error): Impl Display for ErrorKind 2022-02-04 08:37:23 -06:00
Ed Page
4add5723ec refactor(error): Don't constrain start of errors
This also makes the intent for the start of an error clearer.
2022-02-04 08:21:24 -06:00
Ed Page
70b830a1ad refactor(error): Prepare for adding more app fields 2022-02-03 13:05:10 -06:00
Ed Page
00af9c11f8 refactor(error): Shift focus to modern fields 2022-02-03 12:59:59 -06:00
Ed Page
27469dc740 refactor(error): Centralize new formatting 2022-02-03 12:36:20 -06:00
Ed Page
1b66585dc2 feat(error): New error context API
This is meant to replace `Error::info` as part of #2628.
2022-02-03 12:30:49 -06:00
Ed Page
59b63aea51 refactor(error): Pull out kind mod 2022-02-02 16:13:26 -06:00
Ed Page
2d01331540 refactor(error): Prepare for splitting mod 2022-02-02 16:06:23 -06:00
Ed Page
03832c75b9 refactor: Reduce reliance on soon-to-deprecate kind 2022-02-02 15:47:47 -06:00
Ed Page
3b516a4d62 perf(error): Reduce stack size of Error 2022-02-02 15:46:45 -06:00