Commit graph

35 commits

Author SHA1 Message Date
Ed Page
2e3540355a fix(derive): Don't change case of Arg id's (unstable)
This will make it easier to reference arguments with different
attributes.

Fixes #3282
2022-05-09 10:36:03 -05:00
Ed Page
f7e4dd23d6 refactor(derive): Divide rename_all assertions 2022-05-06 16:47:52 -05:00
Ed Page
ddc9d54f41 refactor(derive): Generalize test name 2022-05-06 16:45:03 -05:00
Ed Page
fe4888d668 refactor(derive): Group subcommand rename tests 2022-05-06 16:43:23 -05:00
Ed Page
65538e21a8 fix(derive): Detect escaped ambiguous subcommands (unstable) 2022-05-06 15:46:34 -05:00
shir0kamii
fb4755d1c3 feat(derive): Don't abort when non-unit variant is skipped 2022-03-31 18:49:21 +02:00
plaflamme
154c0d0c65
test: Add test to demonstrate regression 2022-03-06 23:09:55 -05:00
Ed Page
cb937641fa fix(derive): Allow other attributes with subcommand that has subcommands
This was overlooked when we added support for `#[clap(subcommand)]` to
variants.

Fixes #3504
2022-02-23 09:23:33 -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
c4144d7d6c docs: Update App references to Command 2022-02-14 15:33:49 -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
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
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
4538d618a7 refactor: Migrate off of .kind 2022-02-01 11:27:08 -06:00
Peter Grayson
7eea7d27ad
fix(help): Optional arg values in brackets
When an Arg uses .min_values(0), that arg's value(s) are effectively
optional. This is conventionaly denoted in help messages by wrapping the
arg's values in square brackets. For example:

    --foo[=value]
    --bar [value]

This kind of argument can be seen in the wild in many git commands; e.g.
git-status(1).

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
2022-01-26 12:03:23 -05:00
Ed Page
3326a11be0 fix(derive): Don't assume use clap::ArgEnum
The error was when doing `#[clap(arg_enum, default_value_t = ...)]`.

Good example of why we should minimize `use`, at least in tests
(besides reducing merge conflicts, code churn, etc).
2022-01-10 15:41:58 -06:00
Noa
ffd991f0ae
chore: Fix clap_derive license headers 2022-01-04 14:25:48 -06:00
Ed Page
6b9ae5404c fix(derive): Don't enit warnings
We missed covering `Args` warnings when using struct variants.

Fixes #3245
2022-01-03 11:35:34 -06:00
Ed Page
8924dd7a1e feat(derive): Don't require Display for default ArgEnum
While I'm unsure how much type specialization we should do, we
intentionally have the `arg_enum` attribute for doing special behavior
based on it, so let's take advantage of it.

Fixes #3185
2021-12-16 09:11:32 -06:00
Ed Page
9e64387ef0 revert(help): Partial revert of 3c049b4
The extra whitespace was targeted at machine processing for a subset of
users for a subset of runs of CLIs.  On the other hand, there is a lot
of concern over the extra verbose output.

A user can set the help template for man, if desired.  They can even do
something (env? feature flag?) to make it only run when doing man
generation.  We also have #3174 in the works.

So let's focus on the end-user reading `--help`.  People wanting to use
`help2man` have workarounds to do what they need.

Fixes #3096
2021-12-15 10:36:59 -06:00
Ed Page
d55f040bbd fix(derive): Set both about/long_about with doc comments
The main care about is that when we override a `flatten` / `subcommand`
doc comment in a parent container, that we make sure we take nothing
from the child container, rather than implicitly taking one `about` ut
not `long_about`.

To do this, and to play the most safe with long help detection, we reset
`long_about` to default when there is no doc comment body to use for
`long_about`.

Fixes #2983
2021-12-14 11:07:57 -06:00
Ed Page
1811f5e7af test(derive): Show current doc comment behavior
Based on #2983
2021-12-14 11:07:54 -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
703238f155 test(derive): Check all derives
There will always be some kind of corner case not covered as code
evolves but this expands the test to all of the basics.
2021-12-10 10:52:30 -06:00
Ed Page
71a564de88 test(derive): Don't parse the actual command line 2021-12-10 10:36:45 -06:00
Frankie Foston
1285c0f885 fix: unqualified result types causing compilation failures with derive implementations 2021-12-10 14:13:26 +00:00
Ed Page
f517c0ede1 docs: Remove author fields 2021-12-06 11:24:23 -06:00
Ed Page
888c27048d docs: Update changelog 2021-12-02 20:26:21 -06:00
Ed Page
500def4904 fix(derive): Smooth out transition for structopt
Adding in a `StructOpt` derive with `structopt` attributes, with
deprecation notices.  Unofrtunately, not as many deprecation warnings as
I would like.  Apparently, you can't do them for a `use` of a derive?  I
also wanted to inject code that would trigger a deprecation notice for
attributes but that would require enough of a refactor that I didn't
consider it worth it.  We are at least providing a transition window
even if it means we'll have to remvoe it next major release without a
deprecation warning.
2021-12-02 20:18:33 -06:00
Ed Page
b190a6a817 test: Consolidate clap tests
This reduces the need for us to have `clap` as a dependency in
`clap_derive`, preparing the way to fix #15.
2021-11-30 10:07:08 -06:00