Commit graph

1764 commits

Author SHA1 Message Date
Richard Janis Goldschmidt (Beckert)
f9f778e8a4 Fix finding required arguments in group arguments (#829)
This fixes #827. The problem was that the check `grp.args.contains(&grp.args[i])` was a) trivially fulfilled (of course `grp.args[i]` is contained in `grp.args`) and b) causing an out-of-bounds error, since the indices were taken from `.required.len()`.

With this change the argument in the group will be removed from the list of required arguments, as intended.
2017-01-29 18:14:04 -08: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
Trevor Spiteri
5b29be9b07 docs: fix link from app_from_crate! to crate_authors! (#822) 2017-01-29 18:13:34 -08:00
Richard Janis Goldschmidt (Beckert)
ed52851c5d Fix confusing, wrong wording in doc (#821) 2017-01-29 18:12:54 -08:00
Homu
d29d7cc0e2 Auto merge of #820 - shepmaster:patch-1, r=kbknapp
Add categories to Cargo.toml

Hi! [crates.io now supports categories][categories], which are a curated list
of topics aimed at helping an end-user coming to crates.io looking for
"a crate to do ______".

We're sending pull requests to selected crates to add categories in order to help
populate the categories and seed their usefulness. We've made a guess at the best
category/categories for this crate; if it doesn't fit, please feel free to take
a look at [all the available categories and their descriptions][categories] and
[the slug values that should be specified in your Cargo.toml][slugs] and pick
different ones. If you have a category in mind that isn't available, you can
[send a PR to this file on crates.io][categories.toml] to propose additional
categories.

Crates can have up to 5 categories, and uploading categories to crates.io
currently requires publishing a new version with a cargo nightly from 2017-01-18
or later (it needs to contain [this PR][cargo-pr]).

We've [published a blog post][blog-post] with further details about categories.
The blog post also talks about the new crates.io support for CI badges, which
you may be interested in adding as well.

Please let me know if you have any questions!

[categories]: https://crates.io/categories
[slugs]: https://crates.io/category_slugs
[categories.toml]: https://github.com/rust-lang/crates.io/blob/master/src/categories.toml
[cargo-pr]: https://github.com/rust-lang/cargo/pull/3301
[blog-post]: http://integer32.com/2017/01/20/categories-and-ci-badges.html
2017-01-21 12:05:57 +09:00
Jake Goulding
8615aee9ac Add categories to Cargo.toml 2017-01-20 11:16:49 -05:00
Homu
70b2ac289e Auto merge of #819 - SuperFluffy:add_note_to_doc, r=kbknapp
Explain how `ArgRequiredElseHelp` and `default_value` interact

When calling the executable without arguments one expects a help message. However, if even one argument has a default value, the validation step of the parser will always see at least one argument, and therefore report success. This effectively disables the settings.
2017-01-19 10:33:15 +09:00
Richard Janis Goldschmidt
f1b11886dc Explain how AppSettings::ArgRequiredElseHelp and Arg::default_value interact
When calling the executable without arguments one expects a help message. However, if even one argument has a default value, the validation step of the parser will always see at least one argument, and therefore report success. This effectively disables the settings.
2017-01-18 17:14:06 +01:00
Homu
ea5ef4f930 Auto merge of #813 - pixelistik:patch-1, r=kbknapp
doc: Fix typo
2017-01-09 10:59:10 +09:00
pixelistik
5de1b6e1c8 doc: Fix typo 2017-01-08 23:45:03 +01:00
Homu
ec9b556192 Auto merge of #811 - Seeker14491:master, r=kbknapp
docs: fix spelling of "guaranteed"
2017-01-08 12:07:27 +09:00
Brian Bowman
4f30a65b9c docs: fix spelling of "guaranteed" 2017-01-07 20:18:59 -06:00
Homu
031df5d639 Auto merge of #809 - kbknapp:issue-636, r=kbknapp
Issue 636
2017-01-06 10:29:09 +09:00
Kevin K
9d88f19181
refactor: 'reverts' a breaking change until further discussion and approval has taken place 2017-01-05 19:26:16 -05:00
Kevin K
15b3f32e5d
chore: increase version 2017-01-04 00:03:10 -05:00
Kevin K
e80fd4d671
tests: adds tests for AppSettings::AllowMissingPositional 2017-01-04 00:02:26 -05:00
Kevin K
6edde30b8e
setting(AllowMissingPositional): allows one to implement $ prog [optional] <required>
Closes #636
2017-01-04 00:02:26 -05:00
Homu
ce083919be Auto merge of #804 - kbknapp:issues-801,694, r=kbknapp
Issues 801,694 and tests overhaul
2017-01-03 15:00:53 +09:00
Kevin K
2fc5acaff7
fixup! tests: adds tests for propogating values down 2017-01-02 23:10:46 -05:00
Kevin K
f967235a90
tests: massively rehauls tests for better debugging and vastly improved error messages/deduplication 2017-01-02 23:05:50 -05:00
Kevin K
c142fb544d
tests: adds tests for propogating values down 2017-01-02 23:05:50 -05:00
Kevin K
985536c8eb
setting(PropagateGlobalValuesDown): adds a setting to allow automatically propagating global args values down through *used* subcommands
Closes #694
2017-01-02 23:05:50 -05:00
Kevin K
20842ed8c2
fix: fixes an issue where the full help message wasn't written when doing App::write_help
Closes #801
2017-01-02 23:05:50 -05:00
Homu
8e942c2b31 Auto merge of #802 - kbknapp:issues-774,777, r=kbknapp
Issues 774,777
2017-01-03 09:24:51 +09:00
Kevin K
bffe636a01 Merge branch 'master' into issues-774,777 2017-01-02 16:46:51 -05:00
Kevin K
fc3800b830
tests: adds tests for wrapping meta help items 2017-01-02 16:44:40 -05:00
Kevin K
ad4691b71a
feat(Help Wrapping): long app names (with spaces), authors, and descriptions are now wrapped appropriately
Closes #777
2017-01-02 16:43:45 -05:00
Kevin K
1f33de5450
imp(Default Values): improves the error message when default values are involved
Closes #774
2017-01-02 16:43:07 -05:00
Homu
446ec981d1 Auto merge of #800 - kbknapp:issue-782-take2, r=kbknapp
Issue 782 take2
2017-01-03 05:59:45 +09:00
Kevin K
9c3cb9834c
bench: adds a bench with short circuiting some calls via ArgsNegateSubcommands 2017-01-02 14:38:17 -05:00
Kevin K
aa26a50d5c
tests: adds tests to guard against low index multiples with allow_hyphen_values failing 2017-01-02 14:34:25 -05:00
Kevin K
26c670ca16
fix(Low Index Multiples): fixes a bug which caused combinations of LowIndexMultiples and allow_hyphen_values to fail parsing 2017-01-02 14:33:56 -05:00
Kevin K
20a2d95ddf
chore: bumps term_size version 2017-01-02 12:23:03 -05:00
Kevin K
baff4200a4
refactor: implements BitOr for AppFlags to improve some ergonomics and performance 2017-01-02 12:23:03 -05:00
Kevin K
9d9683feb0
tests(Arg::value_terminator): adds tests for Arg::value_termintaor 2017-01-02 12:23:03 -05:00
Kevin K
be64ce0c37
api(Arg::value_terminator): adds the ability to terminate multiple values with a given value
One can now specificy a value termintaor that will stop the parsing of multiple values upon
reaching this special value.

Closes #782
2017-01-02 12:23:03 -05:00
Homu
3ca4a08f0f Auto merge of #798 - nabijaczleweli:feat/778-simple-cargo-app, r=kbknapp
Implement crate_description!, crate_name! and app_from_crate! macros

Includes documentation.
2017-01-01 07:04:16 +09:00
nabijaczleweli
4d9a82db8e
feat(simple-cargo-app): Implement crate_description!, crate_name! and app_from_crate! macros
Closes #778
2016-12-31 14:25:59 +01:00
Homu
805b9b65a3 Auto merge of #797 - kbknapp:three-new-settings-and-a-fix, r=kbknapp
Three new settings and a fix
2016-12-31 14:21:31 +09:00
Kevin K
12026f63d9
tests: adds tests for 2016-12-30 23:22:09 -05:00
Kevin K
5e2af8c96a
setting: adds a setting to disable args being allowed between subcommands (ArgsNegateSubcommands)
Specifies that use of a valid [argument] negates [subcomands] being used after. By default
`clap` allows arguments between subcommands such as
`<cmd> [cmd_args] <cmd2> [cmd2_args] <cmd3> [cmd3_args]`. This setting disables that
functionality and says that arguments can only follow the *final* subcommand. For instance
using this setting makes only the following invocations possible:

* `<cmd> <cmd2> <cmd3> [cmd3_args]`
* `<cmd> <cmd2> [cmd2_args]`
* `<cmd> [cmd_args]`

Closes #793
2016-12-30 23:21:28 -05:00
Kevin K
25cbca4e41
tests: adds tests for 2016-12-30 22:40:28 -05:00
Kevin K
c2978afc61
setting: adds a new setting to disable the collapsing of positional args into [ARGS] in the usage string (DontCollapseArgsInUsage)
Closes #769
2016-12-30 22:38:42 -05:00
Kevin K
945acffb5e
chore: bumps pinned nightly for clippy CI builds 2016-12-30 22:10:14 -05:00
Kevin K
c20701b74a
chore: clippy run 2016-12-30 22:08:28 -05:00
Kevin K
fabe9267ee
chore: updates deps and pins pre-1.0 crates 2016-12-30 22:03:36 -05:00
Kevin K
01caf84b87
tests(DisableHelpSubcommand): adds tests for AppSettings::DisableHelpSubcommand 2016-12-30 21:53:58 -05:00
Kevin K
a10fc859ee
setting: adds a setting to disable building the help subcommand (DisableHelpSubcommand)
Relates to #787
2016-12-30 21:52:45 -05:00
Kevin K
d34ec3e032
fix(Help Subcommand): fixes a bug where the help subcommand couldn't be overriden
Closes #787
2016-12-30 21:37:09 -05:00
Kevin K
85ea57835d
chore: updates the contributing instructions 2016-12-30 21:23:19 -05:00