Commit graph

372 commits

Author SHA1 Message Date
Ed Page
47d76742eb feat: Add Arg getters for all settings
This is prep for #2717
2022-02-10 10:18:41 -06:00
josh rotenberg
ee3eab1614 docs(tutorial): Demonstrate custom parsing
Adds a more in depth validator to validate that the port is in range in the derive and builder tutorial (section 4.2).

This supersedes #3416
2022-02-09 09:16:57 -06:00
Ed Page
06b6714a48 docs(contrib): Call out parallel tutorials 2022-02-08 07:08:14 -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
0dfdeb07bc test: Update 2022-02-07 13:28:48 -06:00
Ed Page
d318752cac docs(derive): Expand on parse attribute 2022-02-02 10:37:47 -06:00
mikehoyle
50b3d2966e
Correct README syntax for bool flag (#3346)
The proper syntax for the attribute is "parse" not "parser".
2022-01-26 08:41:09 -06:00
Ed Page
f32d640d49 docs(tutorial): Talk about required/optional subcommands
Inspired by https://github.com/clap-rs/clap/discussions/3342

Looks like we already cover this in the derive reference.
2022-01-25 09:39:14 -06:00
omjadas
86c83d296f
feat: Add default_value_os_t (#3333)
The order of suffixes allows us to preserve the original builder function name.

This is a part of #2813
2022-01-24 15:32:21 -06:00
Ed Page
ddad3a7923 docs(derive): Clarify from_flag's interactions 2022-01-20 09:55:13 -06:00
Ed Page
63a36673e1 docs(derive): Link ref to tutorial / examples 2022-01-11 14:27:39 -06:00
Ed Page
6b3248fff1 docs(derive): Link tutorial to reference 2022-01-11 14:22:54 -06:00
Ed Page
4b51b8e253 docs(examples): Steer people to know about about vs long_about
`#[clap(about)]` only overrides `about`.  If the doc comment also sets
`long_about`, it won't be overridden.  This change is to help raise
visibility of reseting `long_about` in these cases.
2022-01-10 18:47:24 -06:00
Ed Page
64d16bbc03 docs(derive): Clarify which Cargo.toml field is read 2022-01-10 18:32:32 -06:00
Ed Page
c5ace9aaa6 docs(derive): Clarify what can be used with flatten 2022-01-10 08:03:59 -06:00
Ed Page
fe56bb112d doc(derive): Clarify need to do long_about = None 2022-01-10 07:25:54 -06:00
Hugo Osvaldo Barrera
7110401595 docs: Fix messed up highlighting
This just affects how it's rendered; rather than attempting to highlight
these blocks as a shell script, they'll get highlighted as console
output.

See the rendered versions for a better comparison.
2022-01-05 11:53:06 -06:00
Daniel Eades
2986a9eee0 style: remove unnecessary lazy evaluations 2022-01-04 09:20:17 -06:00
Ed Page
b0cb2057ea docs(derive): Include name magic attribute
Inspired by #3242l
2022-01-03 06:33:53 -06:00
Ed Page
3bb33387af docs(derive): Remove redundant setting 2022-01-01 19:51:17 -06:00
Ed Page
f596bb3ce8 docs(tutorial): Fix another internal link 2021-12-29 18:07:11 -06:00
Emiel Van Severen
657f32a59b
Fix broken internal link 2021-12-30 01:00:29 +01:00
迷渡
9faec11b84
docs: Fix link to 'Configuring the Parser'
Signed-off-by: 迷渡 <justjavac@gmail.com>
2021-12-24 12:41:09 +08:00
Ed Page
3db09f4dd4 fix: Don't panic on lack of conflicts
Fixes #3197
2021-12-23 13:38:23 -06:00
Ed Page
a37f2908c8 docs(derive): Looks like optional isnt supported
According to #2587
2021-12-23 10:29:34 -06:00
Ed Page
653617d0fd docs(derive): Add flatten/subcommand for variants 2021-12-23 10:27:07 -06:00
Ed Page
5643dddf3e docs(tutorial): Encourage App::debug_assert 2021-12-23 08:41:52 -06:00
Ed Page
efca08341a docs(tutorial): Fix derive anchor links 2021-12-23 08:23:32 -06:00
迷渡
c60d5dd1f0
docs: Fix anchor links 2021-12-23 10:58:14 +08: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
aa270f6aca docs(examples): Add cargo subcommand example 2021-12-15 12:07:29 -06:00
Ed Page
03cb509d6c refactor(examples): Change naming style
This is to make room for a reasonable looking cargo plugin example.

I got lazy and didn't update the tutorials.
2021-12-15 11:12:18 -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
b0f1750e81
Merge pull request #3041 from fishface60/master
Rewrite Multicall handling to just strip path off argv0
2021-12-13 09:21:59 -06:00
p4tr1ck
f3afcee855 examples: Fix typo 2021-12-13 22:34:08 +08:00
DerZade
7c60180e24 docs: Fix copy paste error in example 2021-12-13 11:41:12 +01:00
Richard Maw
38b9645bed fix: Windows Multicall support
The executable suffix is unconditionally stripped off the file path
so that the file name matches subcommands names
without having to add the EXE suffix on different platforms.
2021-12-12 22:08:25 +00:00
Richard Maw
17c64ef42b fix: Example typo 2021-12-12 22:08:25 +00:00
Richard Maw
e3d355fa85 feat: Make Multicall just strip dir from argv0 2021-12-12 22:08:25 +00:00
Hiroaki ITO
c2dc425784
docs: Fix the pacman-like interface example link 2021-12-11 22:22:09 +09:00
Ed Page
cf93d7c75a docs: Fix example output
How did #3112 get merged?
2021-12-09 10:26:01 -06:00
Ed Page
7731ca2d21 docs(derive): Show how to override special types
Fixes #3107
2021-12-09 09:32:33 -06:00
Ed Page
367879ac2a docs: Fix reference to feature flags 2021-12-08 19:25:48 -06:00
Ed Page
32b5520ff1 docs: Call out features used in root examples
mitsuhiko immediately jumped into the examples and got tripped up by the
lack of documentation on feature flags needed.

I limited this to just the root ones because the rest are in a more
proper tutorial that steps through it all.
2021-12-08 16:46:49 -06:00
Pavan Kumar Sunkara
6ae804d084
Merge pull request #3082 from epage/fixes
Misc fixes from clapng fork review
2021-12-08 04:08:49 +00:00
Ed Page
76828fada8 docs: Guide people to missing_docs lint 2021-12-07 21:22:12 -06:00
Ed Page
8708c54e5a
Merge pull request #3081 from clap-rs/pksunkara-patch-1
docs: Link correct example
2021-12-07 21:11:07 -06:00
Pavan Kumar Sunkara
c98d8aac13
docs: Link correct example 2021-12-08 01:27:18 +00:00
Ed Page
c99adcc6c9 docs: Add key-value derive example
This is carried over from the clap_derive examples.  Looking over the
other examples, I feel like they are covered by other examples or by the
derive reference.  We should call out deny missing docs though.
2021-12-07 19:01:55 -06:00
Ed Page
55186f5aa3 docs: Highlight subxcommand help heading 2021-12-07 17:45:57 -06:00
Ed Page
92750c6aa5 docs: Simplify demo 2021-12-07 17:45:57 -06:00
Ed Page
6da9277522 docs(derive): Note Option Vec behavior 2021-12-07 17:45:57 -06:00
Ed Page
b2836c07a7 fix: Gracefully handle empty authors 2021-12-06 11:30:26 -06:00
Ed Page
f517c0ede1 docs: Remove author fields 2021-12-06 11:24:23 -06:00
Ed Page
27acb95cd9 docs: Add Derive API reference
I took more inspiration for organization from `serde.rs` than `docs.rs/structopt`.
2021-12-01 21:23:06 -06:00
Ed Page
7f8b1990bb docs: Iterate on examples from writing ref docs 2021-12-01 14:30:51 -06:00
Ed Page
befee6667b docs: Re-work examples
This creates distinct tutorial examples from complex feature examples
(more how-tos).  Both sets are getting builder / derive versions (at
least the critical ones).
2021-11-30 21:33:52 -06:00
Ed Page
c59598479e Revert "docs(examples): De-duplicate subcommand examples"
This reverts commit bbe32b2667.
2021-11-30 14:56:32 -06:00
Ed Page
267de95bee fix: Change app_from_crate default separator
`":"` isn't ideal, so let's make it at least `"," `.

BREAKING CHANGE: Changed `app_from_crate!()` to use `", "` separator for
authors.
2021-11-30 14:56:17 -06:00
Ed Page
f890bfa93b docs: Focus top-level README 2021-11-30 09:53:25 -06:00
Ed Page
9c4194a5a1 test: Verify examples based on feature flags 2021-11-23 17:10:01 -06:00
Ed Page
bfa02fd418 test: More thoroughly test examples
This ports our example testing over to [trycmd](https://docs.rs/) so
we can:
- More thoroughly test our examples
- Provide always-up-to-date example usage

The old way of testing automatically picked up examples.  This new way
requires we have a `.md` file that uses the example in some way.

Notes:
- Moved overall example description to the `.md` file
- I added cross-linking between related examples
- `14_groups` had a redundant paragraph (twice talked about "one and
  only one"
2021-11-23 13:13:41 -06:00
Ed Page
4c4a2b86a0 refactor: Port over to arg! 2021-11-23 09:37:14 -06:00
Ed Page
6ce9714e2b fix: Deprecate YAML API
Fixes #9
2021-11-22 16:17:46 -06:00
Ed Page
88fff13e71 Revert rename of from_yaml / from_usage
Since usage parser and yaml are on the way to being deprecated (#8, #9),
doing a rename also seems excessive, so rolling it back.

Past relevant PRs:
- clap-rs/clap#1157
- clap-rs/clap#1257
2021-11-22 16:17:46 -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
Ed Page
bbe32b2667 docs(examples): De-duplicate subcommand examples
Not seeing what this example adds over the other ones.  We've already
shown subcommands and shown that `App` has extra behavior for when
definint subcommands.
2021-11-17 15:23:31 -06:00
Ed Page
2ac2fc6005 docs(examples): Be explicit in multicall for what clap does
This better matches our other examples
2021-11-17 15:23:31 -06:00
Ed Page
3be8bcf756 docs(examples): Move unwrap comments to expect statements
This better models what users should be doing and makes it so all
comments are more clear.  In a prior commit, when a changed an `exit` to
`unwrap`, I disliked the fact that I was mixing an unwrap explanatory
comment in with another comment.  This makes them stand apart.
2021-11-17 15:23:31 -06:00
Ed Page
41d3b8f164 docs(examples): Remove unnecessary error check
Rather not confuse the point for users.
2021-11-17 15:23:31 -06:00
Ed Page
7763a7c52a docs(examples): Focus subcommands on main call
The subcommand examples focus on the various ways of looking up
subcommands except for the main one people should be using.   This has
previously caused confusion, see https://github.com/clap-rs/clap/discussions/3000

To keep the examples focused, I only show `ArgMatches::subcommand`.  I
figure the examples are not exhaustive and that for the cases when
someone wants to do something more specialized, they can pull up the
API reference.
2021-11-17 15:23:31 -06:00
Ed Page
93948cc724 docs(examples): Work around non-commutative conflicts
The comments in these examples say that a `conflicts_with` should
override `required`.  This seems to be true one way but not the other,
causing these examples to error out at runtime.
2021-11-17 15:23:31 -06:00
Ed Page
4eba65bfaf docs(examples): Don't use is_present with subcommands
Apparently, this isn't supported anymore.
2021-11-17 15:23:31 -06:00
Ed Page
1f0d86a407 docs(examples): Highlight possible-values in help
Instead of showing the user how to do things manually, let's make the
contrast in `--help` more obvious by not manually listing the possible
values.
2021-11-17 15:23:31 -06:00
Ed Page
6fc9c7cff4 docs(examples): Be consistent in define and read order
This threw me off because the arguments are so similar, I kept relying
on the order but they were swapped.
2021-11-17 15:23:31 -06:00
Ed Page
cdc5026410 docs(examples): Use correct arg keys 2021-11-17 15:23:31 -06:00
Ed Page
7c24e937f8 docs(examples): Provide visual indication of user choice 2021-11-17 15:23:31 -06:00
Ed Page
74d41b6f52 docs(examples): Don't crash when subcommand isn't provided 2021-11-17 15:23:31 -06:00
Ed Page
0a4a2dd36b docs(examples): Provide app_from_crate! example
This consolidates two `crate_*!` macro examples into a `app_from_crate`
example.

- This is more of what we expect users to use
- We've talked about splitting the `crate_*` macros out into their own
  crate.  This shifts the focus to what clap would be providing long
  term
2021-11-17 15:23:31 -06:00
Ed Page
535d663dfc docs(examples): Align quick_examples
`01b` doesn't require `output`, so updating `01a` to match
2021-11-17 15:23:31 -06:00
Ed Page
2df043655f docs(examples): Remove reference to non-existent example 2021-11-17 15:23:31 -06:00
Ed Page
7a59dc3da4 Revert "Automatically read license field from Cargo.toml"
This reverts commit 6898fbde33.

PR #2144 added the `license` field but no consumer has been added since
the (like Issue #1768).  Since this is not ready yet, I am pulling it
from the 3.0 release.

So far, our main route for pulling a feature from the release has
been to put it behind a `unstable-*` feature flag and to create a
stablization tracking issue.  I chose to instead remove the feature
because a write-only field with no effect does not provide values for
people to use in as an early access and so doesn't outweight the cost of
the extra documentation noise and code noise it creates.  Additionally,
keeping an `unstable-` feature around when it has such an unknown path
(and time table) to stalbization feels like it violates YAGNI.  I'm
uncertain how much of this feature we can implement and not create a
legal trap for users because the crate's license is insufficient for the
final artifact's license.  I feel our stabliazation process sshould be
about iteration and collecting user feedback which this doesn't line up
with.

When someone is ready to tackle #1768, it will be easy to revert this
commit and pick up the work again.

Fixes #3001
2021-11-12 09:55:37 -06: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
bors[bot]
b835ce9061
Merge #2817
2817: Add support for Multicall executables as subcommands with a Multicall setting r=pksunkara a=fishface60



Co-authored-by: Richard Maw <richard.maw@gmail.com>
2021-10-16 00:32:52 +00:00
Richard Maw
636ecaffa2 fixup! make new tests compile but not run without unstable-multicall 2021-10-15 20:59:33 +01:00
Ed Page
59497629e8 docs: Encourage multiple_occurrences
There were fewer occasions than I expected where the use of
`multiple_values` was superfluous and we could instead use the more
predictable `multiple_occurrences`.

In terms of the remaining `multiple` split work, #1772 will take care of the derive
behavior and #2692 will resolve any remaining issues with values vs
occurrences in positional arguments.

Fixes #2816
2021-10-15 11:41:40 -05:00
Richard Maw
694329b363 fixup! Make hostname a non-derive example and rename via Cargo.toml 2021-10-12 22:38:43 +01:00
Richard Maw
a31d3b288d fixup! Revert: Make hostname a non-derive example and rename via Cargo.toml
tests/examples.rs:examples_are_functional finds examples by stripping
`.rs` off the basename
2021-10-12 20:01:59 +01:00
Richard Maw
1782f9d4ec fixup! Make hostname a non-derive example and rename via Cargo.toml 2021-10-12 19:57:32 +01:00
Richard Maw
971b6b683e fixup! Move explanatory text from examples to docstring 2021-10-11 22:08:51 +01:00
Ed Page
0a53fafddf fix: Deprecate Macro API
Fixes #2835
2021-10-11 15:06:38 -05:00
Richard Maw
1ba4b98b8e fixup! trim hardlink implementation from busybox example 2021-10-11 20:51:33 +01:00
Richard Maw
f14db03eec Add Multicall setting
If the AppSettings::Multicall setting is given
then argv0 is parsed as the first subcommand argument
or parsed as normal with any other name.
2021-10-11 20:00:24 +01: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
rami3l
44ae55fa4e docs(example): clarify stop_parsing_with_-- 2021-08-03 13:41:54 +02:00
rami3l
d7c984896d fix(style): remove unnecessary usages of 'static and ref 2021-08-02 23:05:21 +02:00
Ed Page
c27b2e299c fix(example): Use correct type in comment
Fixes #2631
2021-07-28 10:34:48 -05:00
Pavan Kumar Sunkara
3f94d17c71 Removed Arg::multiple 2021-06-16 07:17:11 +01:00
Tshepang Lekhonkhobe
f8a55930b7
Update examples/18_builder_macro.rs
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-06-12 22:27:27 +02:00
Tshepang Lekhonkhobe
7d9d6f3e51
Update examples/08_subcommands.rs
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-06-12 22:25:56 +02:00
Tshepang Lekhonkhobe
661024a521 the word "Subcommand" was accidentally removed
Was done in 03333800fe
2021-06-11 22:41:37 +02:00
Pavan Kumar Sunkara
82e42cd07e Ignore extra fields in YAML only when specified 2021-06-01 21:59:44 +01:00
Nick Zana
a637d96d82
Fix minor typos in 10_default_values.rs 2021-04-01 17:41:17 -04:00
ldm0
886b873709 Demangle interlinking flags 2021-03-09 13:45:11 +00:00
Pavan Kumar Sunkara
6634444c3c Remove Arg::settings to be consistent with App 2021-02-12 10:42:38 +00:00
Bowen Ding
3907e11621
Make @group accept multiple attributes (#2248)
* Make @group accept multiple attributes.

* New syntax: remove parenthese and "=>".

* Fix example

* Make Clippy happy

* Make clippy happy again
2021-01-23 13:12:40 +00:00
Robin Moussu
6898fbde33 Automatically read license field from Cargo.toml 2020-12-09 00:16:19 +01:00
Derek Mahar
ee76fbf3c5 Make debug option in example 01a_quick_example follow specification. 2020-09-18 12:02:03 -04:00
Derek Mahar
2b369b2ccd Modify debug option to conform to specification. 2020-09-16 21:37:58 -04:00
Matt Kantor
b41384d320 Make all examples compile & run without failure. 2020-08-23 11:23:43 -07:00
CreepySkeleton
0b2eac4da7 Fix yaml support 2020-08-15 23:42:23 +03:00
CreepySkeleton
e9759a241b Adjust examples and tests 2020-08-05 17:07:13 +03:00
João Marcos
24760bc261 style: replacing yml with yaml for consistency 2020-07-20 20:58:34 -03:00
Marti Raudsepp
594c535ba2 Fix various typos in docs & code
Most errors detected and fixed with Topy (https://github.com/intgr/topy),
all verified by hand.
2020-07-19 03:10:28 +03:00
NickHackman
21436398a2 docs: improved flag subcommand documentation
Improved documentation in flag subcommand example and in
`App::short_flag` and `App::long_flag` method documentation.
2020-07-16 17:48:00 -04:00
NickHackman
8a68f99750 example: more pacman-like and refractor
Removed user facing panics and improved ergonomics to behave more like
pacman behaves.
2020-07-07 21:26:38 -04:00
NickHackman
806d7487c6 example: updated 23 docs & refractor
Improved printing instead of printing out the `Vec` using `{:?}`,
`join(", ")` for improved printing. Improved documentation to b emore
explicit and apply to removal of `FlagSubCommand` -> `App::short_flag`
and `App::long_flag`
2020-06-16 20:01:19 -04:00
NickHackman
458736bee8 imp: Improved Flag Subcommand API
Instead of a `FlagSubCommand` struct the addition of two simple methods
to `App`. `App::long_flag` and `App::short_flag` that cover all the
bases of the many methods that were provided in `FlagSubCommand`. This
API is far simpler to use and more akin to the present `Arg::long` and `Arg::short`.
2020-06-15 21:52:36 -04:00
NickHackman
50829711ef examples: FlagSubCommand pacman
Using `pacman` as an example for `FlagSubCommand` because of #1361
2020-06-13 12:32:17 -04:00
Gonçalo Ribeiro
fb8e0d815d docs: correct some typos 2020-05-30 11:14:47 +01:00
Pavan Kumar Sunkara
7bc282dd4e Rename with_name to new for Arg & ArgGroup 2020-05-14 22:50:56 +02:00
kevinlmadison
195b6cb245 fix typo in example 04_using_matches.rs 2020-05-12 00:30:03 +02:00
CreepySkeleton
56fdfb9edd Eradicate warnings and errors: tests and examples 2020-05-02 23:33:47 +03:00
CreepySkeleton
ec6b6e1e36 Make validator take &str instead of String 2020-05-01 14:21:11 +03:00
creativcoder
92d5920748 Updated test and usage of older help APIs with about 2020-04-27 02:42:07 +05:30
Pavan Kumar Sunkara
dbe6ac01f6 Clean up arg_enum 2020-04-22 14:38:16 +02:00
CreepySkeleton
af95c2b6a4 Replace value_t*! macros with methods 2020-04-13 04:20:09 +03:00
CreepySkeleton
5d9ef1527f Fix warnings in tests & examples 2020-03-05 13:40:25 +03:00
bors[bot]
e4a7f50128
Merge #1669
1669: refactor: Rename Arg::conflicts_with_everything to Arg::exclusive (#1… r=pksunkara a=CreepySkeleton



Co-authored-by: Gregor Pfeifer <gpfeifer@dxc.com>
2020-02-22 21:58:29 +00:00
Pavan Kumar Sunkara
5b3a0dff9c Remove extern & macro_use where possible 2020-02-07 07:34:01 +01:00
Gregor Pfeifer
7781fd8813 refactor: Rename Arg::conflicts_with_everything to Arg::exclusive (#1583) (#1624)
https://github.com/clap-rs/clap/pull/1624#issuecomment-571372359
2020-02-04 18:02:47 +03:00
Alex van de Sandt
050bb7484a Fix formatting 2020-02-03 13:04:07 -05:00
Alex van de Sandt
e068826e62 Remove mention of macro_use in doc comment 2020-02-03 12:01:36 -05:00
Alex van de Sandt
81b8bdd7fc Remove #[macro_use] from examples 2020-02-03 12:01:36 -05:00
danieleades
af45420027 style: format code with rustfmt (#1632)
> incidentally, how do we feel about adding a rustfmt check to the CI(s)?
yes we should be doing that. you can send another pr that adds the check to the Ci
2020-01-11 23:45:46 +05:30
Gregor Pfeifer
6180d42c00 feat: Add Arg::conflicts_with_everything method #1583 (#1624)
* feat: Add `Arg::conflicts_with_everything` method #1583

* fix: Typo in  src/build/arg/mod.rs

Co-Authored-By: Dylan DPC <dylan.dpc@gmail.com>

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-06 00:16:28 +05:30
Oleksii Filonenko
1e39967044
Fix some clippy lints
- Manually fix some problems
- Run 'cargo fix --clippy'

Commits taken from similar PRs open at that time:

- Replace indexmap remove with swap_remove
  Resolves #1562 and closes #1563
- Use cognitive_complexity for clippy lint
  Resolves #1564 and closes #1565
- Replace deprecated trim_left_matches with trim_start_matches
  Closes #1539

Co-authored-by: Antoine Martin <antoine97.martin@gmail.com>
Co-authored-by: Brian Foley <bpfoley@users.noreply.github.com>
2019-10-29 21:46:25 -04:00
fvkramer
4e1da91fb1
examples: Change flag arg to option arg
Comments in 04_using_matches.rs list the config arg
as an optional arg. However, -c --config is currently
a flag arg. This commit sets takes_value to true on
the config arg to make it an "option" argument.
2019-10-29 21:45:58 -04:00
Dylan DPC
ee808f464f
Update 17_yaml.yml 2019-07-25 12:14:05 +02:00
Erick Tryzelaar
4a20c6aaef Fix compiling with "--features yaml" 2019-06-19 16:32:52 -07:00
Kevin K
fcbae1574a
style: rustfmt run 2019-04-05 20:21:33 -04:00
Kevin K
20c72525d2 style: cargo fmt run 2018-11-14 12:05:06 -05:00
Kevin K
441f539ede
Merge pull request #1370 from andrewmiller1/yaml-mismatched-types-char
Yaml mismatched types char
2018-11-08 20:37:44 -05:00
andrewmiller1
78886f917d update yaml example comments 2018-11-04 19:11:48 -06:00
Kevin K
03333800fe refactor: remove code going to other crates and deprecations 2018-10-19 23:31:06 -04:00
Kevin K
eaa0700e7e
style: rustfmt run 2018-08-01 23:13:51 -04:00
Kevin K
94872e00a5
refactor(Arg): changes Arg::short to accept a char instead of &str
Closes #1303
2018-07-23 15:10:12 -04:00
Kevin K
af3264d559 Merge pull request #1272 from bspeice/patch-1
examples: Method rename
2018-06-12 09:54:19 -04:00
Kevin K
3b633e68b1
Merge pull request #1258 from little-dude/warnings
Fix compilation warnings
2018-05-22 09:43:31 -04:00
Corentin Henry
dcf00b76eb fix unused import warning 2018-04-21 13:06:11 -07:00
Corentin Henry
4f602b7e86 replace Arg::from_usage by Arg::from 2018-04-21 11:59:19 -07:00
Kevin K
1ab10275e4
style: rustfmt run 2018-01-25 12:21:17 -05:00
discosultan
67e937acf7 Fix typo in 07_option_args.rs 2018-01-18 14:21:02 +01:00
discosultan
8aa3c57351 Fix typo in 07_option_args.rs 2018-01-18 14:16:15 +01:00
Jaanus Varus
354cefd274
Fix typos in 03_args.rs 2018-01-18 13:20:02 +01:00
Jaanus Varus
eb9269a23b
Fix doc typo in 14_groups.rs 2018-01-16 19:54:14 +01:00
Matt Kraai
cc341243f3
Fix typos 2018-01-10 21:49:40 -08:00
messense
2c86c8eb4c Make -- mandatory for the slop example 2017-07-21 09:39:24 -04:00
Dru Sellers
4824fccfb9 Add slop example 2017-06-10 17:38:53 -04:00
Guanqun Lu
34a7436dd3 trivial typo fixes 2017-05-11 20:52:35 -04:00
Martin Geisler
d6743bb70d Fix compilation warnings (#825)
* tests: remove unnecessary mut

When building the projec, I was told

    warning: variable does not need to be mutable, #[warn(unused_mut)]
    on by default
      --> tests/macros.rs:39:9
       |
    39 |     let mut app = clap_app!(("app name with spaces-and-hyphens") =>
       |         ^^^^^^^

* examples: remove unused variable

The inner Some value is not used in the match arm:

    warning: unused variable: `local_matches`,
    #[warn(unused_variables)] on by default
       --> examples/20_subcommands.rs:128:32
        |
    128 |                 ("local", Some(local_matches)) =>{
        |                                ^^^^^^^^^^^^^
2017-01-29 18:13:49 -08:00
Arnavion
f41ec962c2 feat(clap_app!): Support --("some-arg-name") syntax for defining long arg names
Used for arg names that aren't idents.

Ref #321
2016-12-12 22:42:11 -08:00
Kevin K
0e0f33547a
docs(Examples): adds subcommand examples
Closes #766
2016-12-07 15:28:21 -05:00
Wim
c22fbc0735 docs: Fix typo in example 13a_enum_values_automatic 2016-10-30 20:03:05 +01:00
mvaude
847f719921 fix(yaml-example): inconsistent args
change yaml example to be consistent with its configuration

fix #707, #708
2016-10-27 15:12:12 +02:00
tormol
cd516006e3 imp: Stabilize clap_app!
It was de-stabilized in 2.0.0 but hasn't been changed since.

This commit also updates docs to reflect that the "unstable" feature does nothing now.
2016-10-16 21:33:52 +02:00
Kevin K
6b9bd215c1
docs(Default Values): adds better examples on using default values
Closes #418
2016-09-18 16:01:27 -04:00
Kevin K
b7793a2f4d Issues rollup (#637)
* feat: adds App::with_defaults to automatically use crate_authors! and crate_version! macros

One can now use

```rust
let a = App::with_defaults("My Program");

// same as
let a2 = App::new("My Program")
	.version(crate_version!())
	.author(crate_authors!());
```

Closes #600

* imp(YAML Errors): vastly improves error messages when using YAML

When errors are made while developing, the panic error messages have
been improved instead of relying on the default panic message which is
extremely unhelpful.

Closes #574

* imp(Completions): uses standard conventions for bash completion files, namely '{bin}.bash-completion'

Closes #567

* imp(Help): automatically moves help text to the next line and wraps when term width is determined to be too small, or help text is too long

Now `clap` will check if it should automatically place long help
messages on the next line after the flag/option. This is determined by
checking to see if the space taken by flag/option plus spaces and values
doesn't leave enough room for the entirety of the help message, with the
single exception of of if the flag/option/spaces/values is less than 25%
of the width.

Closes #597

* tests: updates help tests to new forced new line rules

* fix(Groups): fixes some usage strings that contain both args in groups and ones that conflict with each other

Args that conflict *and* are in a group will now only display in the
group and not in the usage string itself.

Closes #616

* chore: updates dep graph

Closes #633

* chore: clippy run

* style: changes debug header to match other Rust projects

* chore: increase version
2016-08-27 23:42:31 -04:00
Kevin K
b6c99e1377 docs(YAML): fixes example 17's incorrect reference to arg_groups instead of groups
Closes #601
2016-07-25 20:15:58 -04:00
Roman A. Taycher
05edc4338e removed unstable gate from crate_authors 2016-07-23 15:56:42 -07:00
Hendrik Sollich
6ba910e89b test: adds failing doc test 2016-05-11 20:16:56 +02:00
Roman A. Taycher
ac46864381 move import inside function to avoid conditional compilation warning 2016-04-11 16:49:39 -07:00
Roman A. Taycher
38fb59abf4 feat(Authors Macro): adds a crate_authors macro
Adds a crate_authors! macro that fetches
crate authors from a (recently added)
cargo enviromental variable populated
from the Cargo file. Like the
crate_version macro.

Closes #447
2016-04-11 16:17:44 -07:00
Kevin K
ab41be700b imp(arg_enum): enum declared with arg_enum returns [&'static str; #] instead of Vec 2016-01-31 08:23:34 -05:00
Kevin K
90542747ac chore: fixes doc and style mistakes 2016-01-28 21:58:40 -05:00
Kevin K
f8692a0b3a docs: updates examples for 2x release
Closes #394
2016-01-28 11:46:12 -05:00
Kevin K
c3e96232c9 tests(v2): fixing more tests on the new v2 base 2016-01-28 11:45:31 -05:00
Kevin K
0031d78564 refactor(v2): improving macros for code dedup 2016-01-28 11:45:31 -05:00
Kevin K
7fc18e685f test(v2): fixing tests to pass under new v2 changes 2016-01-28 11:45:31 -05:00
Sung Rim Huh
3936b28035 tests(yaml): use scope wide attribute 2016-01-11 21:13:14 -08:00
Sung Rim Huh
575de089a3 examples(17_yaml): conditinonally compile 17_yaml example 2015-12-08 21:10:00 -08:00
Kevin K
945b00a0c2 docs: fixes panic in 14_groups example
Closes #295
2015-10-01 10:20:04 -04:00
Kevin K
7005cf8c47 style: removes trailing whitespace 2015-09-30 23:59:40 -04:00
Nelson Chen
f85640f9f6 docs: fixes various typos and spelling 2015-09-20 16:59:32 -07:00
Alexander Kuvaev
4ba6249c3c examples: add clap_app quick example 2015-09-09 16:21:59 +03:00
James McGlashan
443841b012 feat: Builder macro to assist with App/Arg/Group/SubCommand building 2015-09-08 22:53:31 +10:00
Alexander Kuvaev
9b84862229 examples(17_yaml): fixed example 2015-09-02 01:09:08 +03:00
Kevin K
82a09abb32 Merge branch 'issue-205' of https://github.com/Vinatorul/clap-rs into vin-issue-205 2015-09-01 00:05:54 -04:00
Kevin K
0e53642a85 chore: fixes .travis.yml for building with yaml feature of clap
Closes #80
2015-08-31 23:59:35 -04:00
Kevin K
ab41d7f382 docs(YAML): adds examples for using YAML to build a CLI 2015-08-31 23:57:35 -04:00
Kevin K
8cbacd8883 docs(Examples): adds better usage examples instead of having unused variables 2015-08-30 16:29:45 -04:00
Kevin K
4f836ee5ef refactor(Examples): corrects compiler warnings about names
Closes #204
2015-08-30 15:43:57 -04:00
Alexander Kuvaev
5a8e341e8e refactor(ArgGroup): changed Vec<&str> using to &[&str] 2015-08-30 20:22:26 +03:00
SungRim Huh
12705079ca examples: Add AppSettings example 2015-08-27 23:35:08 -05:00
SungRim Huh
b9997d1fca examples: add custom validator example 2015-08-27 10:50:39 -05:00
SungRim Huh
d4f1b740ed examples: fix indentation 2015-08-27 10:50:05 -05:00
Kevin K
a5b8b3584b test: fixes tests for 1.0 and deprecated functions 2015-06-29 22:21:47 -04:00
Kevin K
ebf442ebeb docs: updates docs to new version flag defaults 2015-06-16 20:46:11 -04:00
Tshepang Lekhonkhobe
8891d92917 docs(clap): fix typos caught by codespell
Thanks to [tshepang](https://github.com/tshepang) for catching these!
2015-05-05 22:02:14 -04:00