Commit graph

111 commits

Author SHA1 Message Date
Ed Page
181eff5541 docs: Fix stale examples
These were broken in #17 and #38 when renaming `hidden` to `hide`.  These
weren't caught because we test with `--all-targets` which is mutually
exclusive with `--doc`.
2021-11-30 12:05:30 -06:00
Ed Page
2288f55cc1 test: Rely on release process for version sync
When we switch to `cargo-release`, it will validate that the auto-update
was performed.  No reason to have an extra dependency during
development.
2021-11-30 09:59:59 -06:00
Kurt Wolf
a9f4d759c0 Allow bash completions to work with an alias (clap-rs/clap#2054) 2021-11-29 09:02:52 -06:00
Ed Page
7e899cd340 Revert "Deprecate Arg::help in favour of Arg::about"
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840

This is part of #16.  clap-rs/clap#1840 wasn't the right call but we
don't have time to make the decision now, so instead of having one
option and changing it in 4.0, this reverts back to clap2 behavior.
2021-11-18 12:25:49 -06:00
dependabot[bot]
33240fcff3
chore(deps): Update pretty_assertions requirement from 0.7 to 1.0
Updates the requirements on [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) to permit the latest version.
- [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases)
- [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md)
- [Commits](https://github.com/colin-kiegel/rust-pretty-assertions/compare/v0.7.0...v1.0.0)

---
updated-dependencies:
- dependency-name: pretty_assertions
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-17 21:34:15 +00:00
Ed Page
66341b3c11 fix: Always respect positional occurrences
When supporting multiple occurrences for positional arguments in #2804,
I added some tests to cover this but apparently simpler cases fail
despite those more complicated cases being tested.

This adds more multiple-occurrences tests for positional arguments,
fixes them, and in general equates multiple values with occurrences for
positional arguments as part of #2692.  There are a couple more points
for consideration for #2692 for us to decide on once this unblocks them
(usage special case in #2977 and how subcommand help should be handled).

I fully admit I have not fully quantified the impact of all of these
changes and am heavily relying on the quality of our tests to carry this
forward.
2021-11-01 14:14:04 -05:00
Ed Page
a065702205 docs(generate): Move derive example to generate
From a users perspective, `clap_derive` is baked into `clap`.
`clap_generate is an add on to `clap`.  So it seems best to have all
`clap_generate` examples in `clap_generate` where a user will look for
them.

Fixes #2939
2021-10-26 14:26:50 -05:00
Jake Shadle
db2a25473a Fix packaging of LICENSE-* files 2021-10-21 14:57:49 +02:00
Ed Page
9f12bfec47 fix!: Rename ArgValue to PossibleValue
In considering potential work for #2683, I realized we might need a type to carry data for
each of the `multiple_values`.  `ArgValue` works both for that and for
possible values, so we need to come up with a better name for one or
both.  Changing `ArgValue`s name now would be ideal since its new in
clap3 and by renaming it, we can reduce churn for users.

While thinking about this, I realized I regularly get these mixed
up, so renaming `ArgValue` to `PossibleValue` I think will help clear
things up, regardless of #2683.
2021-10-19 10:10:37 -05:00
rhysd
012f318c97 feat(doc): Fix many typos in docs, comments and codes found by typos-cli 2021-10-19 10:38:22 +09:00
Pavan Kumar Sunkara
585e995811 Release 3.0.0-beta.5 2021-10-17 17:01:18 +01:00
rhysd
33efcf1665 feat(generate): reduce dependencies of clap_generate (42 to 13) 2021-10-17 14:31:16 +09:00
Ajeet D'Souza
cad1879ab2 Improve bash generator 2021-10-14 22:51:40 +01:00
bors[bot]
11453065c5
Merge #2871 #2872 #2876
2871: Better positional checks r=epage a=pksunkara



2872: Iterate on help_heading to prepare for derive support r=pksunkara a=epage



2876: Generate/bash: add possible_values to completion when available r=pksunkara a=nstinus



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Co-authored-by: Ed Page <eopage@gmail.com>
Co-authored-by: Nicolas Stinus <nstinus@latourtrading.com>
2021-10-14 20:23:54 +00:00
Nicolas Stinus
bcf1bb69c8 fix(gen): address clippy suggestion
Change-Id: I11a8dc27956e6365a0c8ae8165e08d2209ae9395
2021-10-14 14:42:04 -04:00
Nicolas Stinus
de1c764905 fix(gen): in bash, pass use possible_values if available
Change-Id: I7a54821666f0ba366379d6cac83898fcd9b76ee6
2021-10-14 14:41:11 -04:00
Pavan Kumar Sunkara
f371cfed29 fix: Better positional checks 2021-10-14 09:26:53 +01:00
Pavan Kumar Sunkara
2454dabc03 refactor: Remove get_flags API 2021-10-14 09:26:09 +01:00
Ed Page
a61b60816c fix(gen): Ensure subcommands are post-processed
`App::get_matches` lazily post-processes `App`s and `Arg`s so we don't
do it to subcommands that are never run (downside being people have to
exercise their full app to get debug_asserts).

`clap_generate` was only post-processing the top-level `App` and `Arg`s,
ignoring the sub-commands.  In #2858, we noticed that `--version` was
being left in the completions instead of being removed during the
`_build` step.  We would also have an incorrect `num_vals` and a host of
other problems.

This change adds a `App::_build_all` function for `clap_generate` to use
to eagerly build everything.  By having it there, we make sure
everywhere that needs eager building, gets it (like some tests).

In `clap_generate::utils`, we add a unit test to ensure the subcommand's
`--version` was removed.

For some other tests specifying `.version()`, I added
`AppSettings::PropagateVersion` to make it behave more consistently.
The places I didn't were generally where the version was conditionally
set.

For `clap_generate/tests/generate_completions.rs`, I had to adjust the
`conflicts_with` because the subcommand was inheriting the argument with
it defined *but* the subcommand did not have the argument, tripping up a
debug assert.

Fixes #2860
2021-10-12 15:54:26 -05:00
Ed Page
536471cb7d fix(gen)!: Simplify Generator trait
This is a followup to #2721 where we decided to remove all of the
helpers from the trait.  They are now in a `utils` mod.  A part of me
wants this module to be private but it'd be a lot to duplicate for the
split out modules.

Note: this doesn't update fig.  Fig was never added to the workspace and
is already broken (and not just from #2721).  My plan is to get this
merged and then fix Fig, rather than fix it in multiple passes.
2021-10-12 08:27:24 -05:00
Paul Seyfert
25e337adb1 [clap_generate] [zsh] sort out multiple occurrence vs multiple_value. 2021-10-12 10:48:37 +01:00
Pavan Kumar Sunkara
0a61c8aa08 fix: Whitespace in our generators **is** important and we need to fix it 2021-10-12 02:08:11 +01:00
Pavan Kumar Sunkara
68d0338ddd chore: Minor doc and style changes 2021-10-12 02:08:11 +01:00
Ed Page
73bc22cc3d docs: Bridge the user to 'Shell'
In addition, this raises the visibility of the new `value_hint` feature.
2021-10-11 10:46:44 -05:00
Ed Page
96f2343e1b feat(generate): 'impl Generator for Shell'
This includes updating the example but does not include improving the
jumping-off documentation.
2021-10-11 10:46:44 -05:00
Ed Page
1bbfd956aa test: Harden tests against trailing whitespace
In a follow up commit, my editor stripped trailing whitespace.  Rather
than have everyone fight this, let's not make a deal over the small
stuff.
2021-10-11 10:44:48 -05:00
Ed Page
35d53d9dcf feat(generate): 'impl ArgEnum for Shell'
These keeps `FromStr` for ease of use with `value_of_t`.

This includes adding test to make sure everything works as expected.
2021-10-11 10:44:48 -05:00
Kevin K
14c8850019
tests: fixes test to new default behavior
This commit corrects tests to not expect the `-V,--version` flag when no
version information has been provided.
2021-10-09 11:12:50 -04:00
Kevin K
0addd938a6
tests(Examples): fixes examples for no-auto generated version 2021-10-09 11:06:48 -04:00
Ed Page
6c6b97daa8 docs: Ensure all crates have license files
In #2270, its brought up to solve this at the `cargo workspace publish`
level.  However, copying the files is a 5s fix without any design work,
it doesn't seem like support within an external tool should block us
from getting this fix into users hands.  Once `cargo workspace publish`
supports this and if we are still using it, we can re-evaluate.

Fixes #2270
2021-10-04 14:45:31 -05:00
cherryblossom
f77dceaf69
Fix Elvish completions generation
The `display-suffix` option for `edit:complex-candidate` was [deprecated in Elvish v0.14.0][1] and
removed in v0.15.0 (latest version is v0.16.3), so this commit changes the Elvish completions
generation to use the `display` option instead.

Additionally, this commit changes assignments to use the `var` and `set` keywords as using
`name = value` without these keywords ('legacy assignment form') [will be deprecated][2].

[1]: https://elv.sh/blog/0.14.0-release-notes.html
[2]: https://elv.sh/ref/language.html#legacy-assignment-form
2021-09-24 22:29:05 +10:00
Roland Fredenhagen
5580e8c465
ArgValue builder (#2758)
* feat(arg_value): ArgValue can be used for possible_values

Through the ArgValue it is possible:

* `hide` possible_values from showing in completion, help and validation
* add `about` to possible_values in completion

* Resolved a few change-requests by epage

* make clippy happy

* add ArgValue::get_visible_value

* remove verbose destructering

* rename ArgValue::get_hidden to ArgValue::is_hidden

* add test for help output of hidden ArgValues

* Documentation for ArgValue

There is an issue that required to implement From<&ArgValue> for
ArgValue. We should probably find a solution without that.

* fix requested changes by epage

* fix formatting

* add deref in possible_values call to remove From<&&str>

* make clippy happy

* use copied() instad of map(|v|*v)

* Finishing up for merge, hopefully

* changes requested by pksunkara
2021-09-19 10:29:09 +00:00
Roland Fredenhagen
c01df8da40
doc(generate) fix link in generate_to 2021-09-09 13:04:01 +02:00
Roland Fredenhagen
0105e6f0b8
fix(generate): Better subcommand completion in fish (#2726)
* fix(generate): Better subcommand completion in fish

* Prevent completing subcommands that were already completed

* Make sure all parent subcommands actually existent

Partially fixes #2715

* Added Test

* fix(generate) Improve subcommand testing

This now also disables the completion of sub_subcommands options for
subcommands.
2021-09-08 15:32:26 +01:00
ModProg
f6ccf07de4 Fix Formatting 2021-08-21 01:00:51 +02:00
ModProg
174e004107 fix(generate): Hide option/argument description for argenum
This returns `"{a\t,b\t}"` instead of `"a b"` for possible_values
completion. Therefore fish displays and therefor hides the empty
description after the `\t`.

Fixes #2727
2021-08-21 00:53:10 +02:00
Ed Page
f2586c920f docs: Point out alternatives to 'build.rs' 2021-08-18 12:10:04 -05:00
Ed Page
13a93ab671 docs(generate): Improve jumping off points
This provides a skeleton README for `clap_generate`, including a
one-line summary and a link to the docs to guide people to the examples
there.

In doing so, I tried to clarify and be consistent in what role
this crate plays.  While it is very general, being too general in the
description can lead people to not understand where they could use it.

Fixes #1711
2021-08-18 12:10:04 -05:00
Donough Liu
b1d364a228
Pin clap_derive version (#2706)
* Pin clap_derive version

* Pin clap version in clap_generate
2021-08-17 08:43:37 +00:00
Pavan Kumar Sunkara
52be134949 Release 3.0.0-beta.4
clap@3.0.0-beta.4
clap_derive@3.0.0-beta.4
clap_generate@3.0.0-beta.4

Generated by cargo-workspaces
2021-08-14 23:40:49 +01:00
Pavan Kumar Sunkara
73b28fb104 Release 3.0.0-beta.3
clap@3.0.0-beta.3
clap_derive@3.0.0-beta.3
clap_generate@3.0.0-beta.3

Generated by cargo-workspaces
2021-08-14 23:01:13 +01:00
Pavan Kumar Sunkara
6994be4f15 Remove doc feature 2021-07-30 22:49:11 +01:00
patrick-gu
a4dc72ed19 Replace "Prints" with "Print" for default help and version commands 2021-07-29 20:23:25 -07:00
Tshepang Lekhonkhobe
b4eddf158d fix remaining intra-doc links 2021-07-10 21:00:34 +02:00
Rémi Lauzier
48147d680b
Update dependency that need no change 2021-06-17 13:58:40 -04:00
Rémi Lauzier
c4f534228b
Fix some nightly clippy warnings 2021-06-16 23:25:13 -04:00
Pavan Kumar Sunkara
94ce18c399 Update badges 2021-05-25 23:19:32 +01:00
Pavan Kumar Sunkara
3c9cc0cf91 Specify dep patch versions 2021-04-11 10:38:13 +01:00
Ajeet D'Souza
401744e24b Remove old slice syntax 2021-04-08 17:10:17 +05:30
Ajeet D'Souza
34fb411965 Use str:has-prefix in place of has-prefix 2021-04-08 16:51:06 +05:30