Commit graph

1764 commits

Author SHA1 Message Date
Homu
7eb949ba38 Auto merge of #796 - kbknapp:issue-665, r=kbknapp
Issue 665
2016-12-31 07:48:07 +09:00
Kevin K
327c514d7a
test(Options): adds a test against issue 665 2016-12-30 16:25:48 -05:00
Kevin K
5a5f2b1e9f
fix(Options): fixes a critical bug where options weren't forced to have a value
For instance imagine --opt <val> and --opt2 <val>

Running:

```
$ prog --opt --opt2 val
```

Would pass. This has been fixed.

Closes #665
2016-12-30 16:17:47 -05:00
Homu
03f72335a9 Auto merge of #795 - kbknapp:issue-792, r=kbknapp
style: standardizes debug calls and output

Closes #792
2016-12-30 14:30:16 +09:00
Kevin K
988b9cbea4
style: standardizes debug calls and output
Closes #792
2016-12-29 23:34:46 -05:00
Homu
14a08e8619 Auto merge of #794 - kbknapp:issue-764, r=kbknapp
Issue 764
2016-12-30 01:57:11 +09:00
Kevin K
280bb85f69 Merge branch 'master' into issue-764 2016-12-28 23:58:11 -05:00
Kevin K
1c9e8700d4
chore: bumps version in prep for more commits 2016-12-28 23:57:13 -05:00
Kevin K
3055e77ea7
tests(YAML): adds some of the new APIs to the YAML tests 2016-12-28 23:56:33 -05:00
Kevin K
9a4df32789
imp(YAML): adds conditional requirements and conditional default values to YAML
All of the conditional default values and conditional requirements
(requried and requires) can now be used with YAML builders as well.

Closes #764
2016-12-28 23:34:29 -05:00
Kevin K
60e1a3a02b
tests(Conditionally Required): adds tests for conditionally required args 2016-12-28 23:30:52 -05:00
Kevin K
ee9cfddf34
feat(Conditionally Required): adds the ability for an arg to be conditionally required
An arg can now be conditionally required (i.e. it's only required if arg
A is used with a value of V).

For example:

```rust
let res = App::new("ri")
	.arg(Arg::with_name("cfg")
	    .required_if("extra", "val")
	    .takes_value(true)
	    .long("config"))
	.arg(Arg::with_name("extra")
	    .takes_value(true)
	    .long("extra"))
	.get_matches_from_safe(vec![
	    "ri", "--extra", "val"
	]);

assert!(res.is_err());
assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
```

Relates to #764
2016-12-28 23:30:52 -05:00
Kevin K
4ef091019c
docs(Conditional Default Values): fixes the failing doc tests of Arg::default_value_ifs 2016-12-28 23:28:21 -05:00
Kevin K
7f296e29db
docs(Conditional Requirements): adds docs for Arg::requires_ifs 2016-12-28 23:28:21 -05:00
Kevin K
198449d643
feat(Conditional Requirements): adds the ability to conditionally require additional args
An arg can now conditionally require additional arguments if it's value matches a specific value.

For example, arg A can state that it only requires arg B if the value X was used with arg A. If any
other value is used with A, arg B isn't required.

Relates to #764
2016-12-28 23:28:21 -05:00
Kevin K
eca609159a
test(Conditional Requirements): adds teste for conditional requirements 2016-12-28 23:21:40 -05:00
Kevin K
eb4010e7b2
feat(Conditional Default Values): adds new Arg::default_value_if[s] methods for conditional default values
One can now implement conditional default values. I.e. a default value that is only applied in
certain conditions, such as another arg being present, or another arg being present *and*
containing a specific value.

Now it's possible to say, "Only apply this default value if arg X is present" or "Only apply this
value if arg X is present, but also only if arg X's value is equal to Y"

This new method is fully compatible with the current `Arg::default_value`, which gets set only if
the arg wasn't used at runtime *and* none of the specified conditions were met.

Releates to #764
2016-12-28 23:21:40 -05:00
Kevin K
b03eff6df5
tests(Default Values If): adds tests for the new defualt_value_if[s] methods 2016-12-28 23:21:40 -05:00
Homu
30b1bbfaa1 Auto merge of #784 - glowing-chemist:master, r=kbknapp
feat(Validators): adds ability to validate invalid UTF-8

added validator_os
2016-12-29 07:57:19 +09:00
Kevin K
a7186fa8fe Merge branch 'master' into master 2016-12-28 12:01:11 -05:00
Homu
e20009d2ca Auto merge of #790 - kbknapp:issue-shortcircuit-help, r=kbknapp
Issue shortcircuit help
2016-12-29 01:03:58 +09:00
Kevin K
68dadde061 Merge branch 'master' into issue-shortcircuit-help 2016-12-28 09:33:16 -05:00
Oliver Smith
17d70dc38e Merge branch 'master' into master 2016-12-28 12:33:23 +00:00
glowing-chemist
1da29a6266 proper OsString conversion 2016-12-28 12:30:50 +00:00
Kevin K
e79124e4c2
chore: increase version 2016-12-28 04:26:59 -05:00
Kevin K
d3d34a2b51
fix: fixes a bug where calling the help of a subcommand wasn't ignoring required args of parent commands
Closes #789
2016-12-28 04:25:58 -05:00
Jędrzej
6fdd2f9d69 feat(no_cargo): add no_cargo feature to disable Cargo-env-var-dependent macros (#786) 2016-12-27 21:07:59 -05:00
glowing-chemist
47232498a8 feat(Validators): adds ability to validate invalid UTF-8 2016-12-27 23:16:28 +00:00
glowing-chemist
f49fb88aa2 updated 2016-12-27 16:19:42 +00:00
glowing-chemist
a43f32ce52 added validator_os 2016-12-25 18:55:03 +00:00
Björn Steinbrink
eb1d79dbb1 Only colorize missing arguments when appropriate (#781)
Instead of using Format::Error directly, we need to use a Colorizer to
make sure that the message only gets colorized when it is appropriate
to do so.

Fixes #775
2016-12-19 12:47:49 -06:00
Homu
d5361c4598 Auto merge of #780 - nabijaczleweli:fix/779/crate_authors!-newlines, r=kbknapp
Handle replacing colons with custom separators in crate_authors!()

Discussion: #779
r? @kbknapp
2016-12-19 08:30:40 +09:00
Kevin K
83bacb87bb Merge branch 'master' into fix/779/crate_authors!-newlines 2016-12-18 17:08:38 -05:00
nabijaczleweli
315dffc011
Add documentation for new crate_authors!() functionality 2016-12-18 22:43:43 +01:00
nabijaczleweli
15d1619fa2
Default crate_authors!() macro to colon version. Add arm to handle custom separators
This makes default crate_authors!() invocation same as before the
changes
2016-12-18 21:56:44 +01:00
Homu
dd313415af Auto merge of #776 - Arnavion:pr-731, r=kbknapp
Support `("some string")` for app names and long arg names in clap_app!

Previous discussion in #731
2016-12-19 05:44:23 +09:00
nabijaczleweli
05f4953409
Inline lazy_static! even harder in crate_authors!()
Functionality remains the same
2016-12-18 13:39:43 +01:00
nabijaczleweli
1a84ce22bc
Replace colons with newlines in crate_authors!()
The implementation is basically manually expanded lazy_static! macro
(with some hand-crafted simplifications and inlining), since you can't
use extern crates (and therefore import macros therefrom) in macros.

This ensures that you get this:

    p:\Rust\http>target\debug\http -h
    http 0.1.0
    thecoshman <thecoshman@gmail.com>
    nabijaczleweli <nabijaczleweli@gmail.com>
    Host These Things Please - a basic HTTP server for hosting a folder fast and simply

Instead of this:

    p:\Rust\http>target\debug\http -h
    http 0.1.0
    thecoshman <thecoshman@gmail.com>:nabijaczleweli <nabijaczleweli@gmail.com>
    Host These Things Please - a basic HTTP server for hosting a folder fast and simply

Closes #779
2016-12-18 13:17:34 +01: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
Arnavion
9895b671cf feat(clap_app!): Support ("some app name") syntax for defining app names
Used for setting names that aren't Rust idents.

Fixes #759
2016-12-12 22:42:11 -08:00
Arnavion
79bbf57815 tests(clap_app!): Added test for clap_app! macro. 2016-12-12 22:42:11 -08:00
Homu
274afb1f08 Auto merge of #773 - musoke:doc_spelling, r=kbknapp
Spelling in docs

Just some typos I noticed while reading the docs.
2016-12-11 12:02:20 +09:00
Nathan Musoke
f22c21b422 docs(README.md): fix some typos 2016-12-11 11:54:40 +13:00
Nathan Musoke
5c9b0d47ca docs(src/app/mod.rs): fix some typos 2016-12-11 11:36:37 +13:00
Homu
ff5d1a753d Auto merge of #772 - kbknapp:issue-771, r=kbknapp
Issue 771
2016-12-09 11:53:40 +09:00
Homu
ff7febf3f9 Auto merge of #767 - kbknapp:issue-765, r=kbknapp
docs(README.md): adds guidance on when to use ~ in version pinning, a…

…nd clarifies breaking change policy

Closes #765

cc @joshtriplett
2016-12-09 06:02:22 +09:00
Kevin K
7144419598
chore: increase version 2016-12-08 15:41:03 -05:00
Kevin K
7e17d5a36b
fix(ZSH Completions): escapes square brackets in ZSH completions
Since ZSH completions use `[ and ]` for descriptions, but clap args use `[ and ]` for possible
values and other auxillary arg information, this was creating a conflict. clap now escapes any
square brackets before writing the help, i.e. `\\[ and \\]` which removes conflicts.

Alternatives would be to switch `[ and ]` for `( and )` but this would create a slight difference
in help messages and completions.

Closes #771
2016-12-08 15:36:18 -05:00
Kevin K
591eaefc73
docs(README.md): adds guidance on when to use ~ in version pinning, and clarifies breaking change policy
Closes #765
2016-12-08 11:35:38 -05:00
Homu
949690ee4a Auto merge of #768 - kbknapp:issue-766, r=kbknapp
docs(Examples): adds subcommand examples

Closes #766

cc @omtcyfz
2016-12-08 11:10:36 +09:00