Commit graph

1422 commits

Author SHA1 Message Date
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
Kevin K
9605ea83aa chore: increase version (#599) 2016-07-24 00:13:00 -04:00
Barret Rennie
0ceba231c6 feat(Settings): Add unset_setting and unset_settings fns to App (#598)
Closes #590.
2016-07-24 00:08:24 -04:00
Homu
84a08758b2 Auto merge of #596 - rtaycher:authors, r=kbknapp
removed unstable gate from crate_authors

The cargo feature it depends on has been available since april, I think we can make this stable now.
2016-07-24 12:22:47 +09:00
Roman A. Taycher
3398b64b5a Merge branch 'master' into authors 2016-07-23 16:39:29 -07:00
Roman A. Taycher
05edc4338e removed unstable gate from crate_authors 2016-07-23 15:56:42 -07:00
Homu
8830dc4edf Auto merge of #595 - kbknapp:issues-575,593, r=kbknapp
Issues 575,593
2016-07-24 06:52:40 +09:00
Kevin K
625cbbca0d test: adds tests for required_unless_one cases 2016-07-23 17:22:14 -04:00
Kevin K
1fc3b55bd6 fix: fixes bug where only first arg in list of required_unless_one is recognized
Closes #575
2016-07-23 17:21:47 -04:00
Kevin K
fc72cdf591 fix(Settings): fixes typo subcommandsrequired->subcommandrequired
Closes #593
2016-07-23 16:25:17 -04:00
Christopher Field
1b99091e0a tests: adds require_unless_one test cases
* test: `require_unless_one` with second argument

Add the `require_unless_one_2` test. This tests that when the second
argument in the array is used at the command line, that the required
argument is not present. This test was added because it appears the
`require_unless_one` function only works for the first argument in the
array.

* Fix: assertions for test

The assertions did not check for the `infile` to be present.
2016-07-23 13:43:22 -04:00
Homu
af4bb4c6d5 Auto merge of #570 - davidszotten:gen_completion_to, r=kbknapp
add `gen_completions_to`

to write completions to buffer (e.g. stdout) instead of file. fixes #566

(for review; will fix commit message when done)

still pretty new to rust so comments on anything from style to structure would be must appreciated!
2016-07-24 02:21:18 +09:00
David Szotten
9f62cf7378 feat(Completions): adds the ability to generate completions to io::Write object 2016-07-14 09:38:13 +01:00
Homu
691ef58dfb Auto merge of #571 - gohyda:master, r=kbknapp
Fix: typo and missing color
2016-07-14 01:33:19 +09:00
Bence Szigeti
8c32b4b63f Fix: missing color 2016-07-05 23:16:44 +02:00
Bence Szigeti
f8ca3085da Fix: typo -- missing space and commas 2016-07-05 22:14:47 +02:00
Bence Szigeti
8d7bea823f Fix: extra space typo removed 2016-07-05 22:01:04 +02:00
Homu
6398ca435b Auto merge of #569 - iliekturtles:patch-1, r=kbknapp
Fix get_matches typo
2016-07-04 23:35:54 +09:00
Mike Boutin
b3cdc3b5c2 Fix get_matches typo 2016-07-04 10:19:36 -04:00
Homu
3680ce85e3 Auto merge of #565 - kbknapp:issue-563, r=kbknapp
Issue 563
2016-07-04 00:54:41 +09:00
Kevin K
4e60b2254d chore: increase version 2016-07-03 10:55:49 -04:00
Kevin K
cecfe981ea fix(Completions): fixes bug where --help and --version short weren't added to the completion list
Closes #563
2016-07-03 10:55:40 -04:00
Homu
0b4ee665ad Auto merge of #562 - swatteau:fix-compl-doc, r=kbknapp
Fix the formatting in the completions example

A missing newline prevented the Cargo.toml excerpt in the `gen_completions` example from being properly formatted.
2016-07-02 21:30:48 +09:00
Sébastien Watteau
722f2607be docs(Completions): fixes the formatting of the Cargo.toml excerpt in the completions example 2016-07-02 09:31:09 +02:00
Homu
11b92170ef Auto merge of #561 - kbknapp:compl-mult-bin, r=kbknapp
Compl mult bin
2016-07-02 11:41:46 +09:00
Kevin K
9e9d92a3bd chore: increase version 2016-07-01 22:16:47 -04:00
Kevin K
57484b2dae imp(Completions): allows multiple completions to be built by namespacing with bin name
Completions are now written `<bin>_<shell>.<ext>` vice the old, `<shell>.<ext>`
2016-07-01 22:15:23 -04:00
Kevin K
f10375ebe0 Merge pull request #560 from kbknapp/issue-558
Issue 558
2016-07-01 16:14:22 -04:00
Kevin K
c9d17392c5 Merge branch 'master' into issue-558 2016-07-01 14:24:36 -04:00
Homu
453cff59e1 Auto merge of #559 - kbknapp:issues-556,557, r=kbknapp
Issues 556,557
2016-07-02 02:52:46 +09:00
Kevin K
aa95719eba chore: updates changelog and readme for release 2016-07-01 13:51:59 -04:00
Kevin K
93cbb56f77 tests: adds tests for leading hyphen issues 2016-07-01 13:50:32 -04:00
Kevin K
96c24c9a8f fix(AllowLeadingHyphen): fixes an issue where isn't ignored like it should be with this setting
Prior to this fix, using `AppSettings::AllowLeadingHyphen` wouldn't properly ignore `--`

Closes #558
2016-07-01 13:47:41 -04:00
Kevin K
cb251de25c chore: updates readme and changelog 2016-07-01 13:07:08 -04:00
Kevin K
0ab9f84052 imp(Completions): completions now include aliases to subcommands, including all subcommand options
Aliases to subcommands can now be completed just like the original subcommand they alias.

Imagine a subcommand `update` with alias `install`, the `update` subcommand has an option `--pkg`
which accepts a package to update/install.

The following completion would happen:

```
$ prog <tab><tab>
-h --help -V --version install update

$ prog install <tab><tab>
-h --help -V --version --pkg

$ prog install --pkg <tab><tab>
$ prog install --pkg <PACKAGE>

$ prog update <tab><tab>
-h --help -V --version --pkg

$ prog update --pkg <tab><tab>
$ prog update --pkg <PACKAGE>
```

Closes #556
2016-07-01 12:57:37 -04:00
Kevin K
9b359bf062 docs(Completions): fixes some errors in the completion docs 2016-07-01 12:26:20 -04:00
Kevin K
18fc2e5b5a imp(Completions): completions now continue completing even after first completion
Prior to this change, completions only allowed one completion per command, this change allows as
many as required. The one downside to this change is the completion engine isn't smart enough to
determine which options are no longer legal after certain options have been applied.
2016-07-01 12:22:30 -04:00
Kevin K
89cc2026ba imp(Completions): allows matching on possible values in options
Now when one completes an option with possible values, those values will be displayed. Imagine
a program with an `--editor` option, which accepts either `vi`, or `emacs`. The following would
be displayed for completions

```
$ prog --editor <tab><tab>
vi emacs
```

Closes #557
2016-07-01 12:20:16 -04:00
Homu
70fa5f780a Auto merge of #554 - kbknapp:issue-376, r=kbknapp
Issue 376
2016-07-01 20:51:21 +09:00
Kevin K
7daee9ded0 chore: increase version 2016-07-01 00:34:08 -04:00
Kevin K
c6c519e40e docs(Completions): adds documentation for completion scripts 2016-07-01 00:18:52 -04:00
Kevin K
e75b6c7b75 feat(Completions): one can now generate a bash completions script at compile time
By using a build.rs "build script" one can now generate a bash completions script which allows tab
completions for the entire program, to include, subcommands, options, everything!

See the documentation for full examples and details.

Closes #376
2016-06-30 23:50:49 -04:00
Homu
3a000d69d9 Auto merge of #551 - kbknapp:issues-546,549, r=kbknapp
Issues 546,549
2016-06-30 22:25:33 +09:00
Kevin K
e5ba93afd3 chore: increase version 2016-06-29 23:25:14 -04:00
Kevin K
ceddee9157 refactor(term.rs): moved term.rs into it's own crate so others can pull in just that portion
The functionality can now be found in https://crates.io/crates/term_size

Closes #549
2016-06-29 23:19:08 -04:00
Kevin K
98a7e8a636 tests(Arg): adds tests for
Closes #546
2016-06-29 23:01:47 -04:00
Kevin K
49af4e38a5 docs(Arg): adds docs for 2016-06-29 23:00:50 -04:00
Kevin K
920b5595ed feat(Arg): adds new setting Arg::require_delimiter which requires val delimiter to parse multiple values
Using this setting requires a value delimiter be present in order to parse multiple values.
Otherwise it is assumed no values follow, and moves on to the next arg with a clean slate.

These examples demonstrate what happens when `require_delimiter(true)` is used. Notice
everything works in this first example, as we use a delimiter, as expected.

```rust
let delims = App::new("reqdelims")
    .arg(Arg::with_name("opt")
        .short("o")
        .takes_value(true)
        .multiple(true)
        .require_delimiter(true))
    // Simulate "$ reqdelims -o val1,val2,val3"
    .get_matches_from(vec![
        "reqdelims", "-o", "val1,val2,val3",
    ]);

assert!(delims.is_present("opt"));
assert_eq!(delims.values_of("opt").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
```
In this next example, we will *not* use a delimiter. Notice it's now an error.

```rust
let res = App::new("reqdelims")
    .arg(Arg::with_name("opt")
        .short("o")
        .takes_value(true)
        .multiple(true)
        .require_delimiter(true))
    // Simulate "$ reqdelims -o val1 val2 val3"
    .get_matches_from_safe(vec![
        "reqdelims", "-o", "val1", "val2", "val3",
    ]);

assert!(res.is_err());
let err = res.unwrap_err();
assert_eq!(err.kind, ErrorKind::UnknownArgument);
```
What's happening is `-o` is getting `val1`, and because delimiters are required yet none
were present, it stops parsing `-o`. At this point it reaches `val2` and because no
positional arguments have been defined, it's an error of an unexpected argument.

In this final example, we contrast the above with `clap`'s default behavior where the above
is *not* an error.

```rust
let delims = App::new("reqdelims")
    .arg(Arg::with_name("opt")
        .short("o")
        .takes_value(true)
        .multiple(true))
    // Simulate "$ reqdelims -o val1 val2 val3"
    .get_matches_from(vec![
        "reqdelims", "-o", "val1", "val2", "val3",
    ]);

assert!(delims.is_present("opt"));
assert_eq!(delims.values_of("opt").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
```
2016-06-29 22:57:28 -04:00
Homu
40017ed091 Auto merge of #550 - joshtriplett:term-winsize-c, r=kbknapp
fix: Declare term::Winsize as repr(C)

The term module uses the struct Winsize directly in a C ioctl call, so it must use C struct representation.
2016-06-30 10:54:39 +09:00
Josh Triplett
5d663d905c fix: Declare term::Winsize as repr(C)
The term module uses the struct Winsize directly in a C ioctl call, so
it must use C struct representation.
2016-06-29 17:22:31 -07:00