Commit graph

1525 commits

Author SHA1 Message Date
Vinzent Steinberg
58512f2fcb feat(Errors): Errors with custom description
This is useful if a more meaningful message can be displayed to the
user with `Error::exit`. For example, if a file is not found, the
converted `io::Error` will give a message like:

    "error: entity not found"

With this, it is possible to replace this message with a more useful
one, like for instance:

    "error: configuration file not found"

Coloring is respected. Some duplication in the `From::from` impls was
reduced.
2016-09-05 14:54:14 -04:00
Homu
26d5207728 Auto merge of #639 - nabijaczleweli:improvement/help/wrap-use-term_size, r=kbknapp
Use term_size instead of home-grown solution

Ref: #631
2016-09-06 00:18:42 +09:00
nabijaczleweli
fc7327e9dc
imp(help): use term_size instead of home-grown solution 2016-08-29 07:36:06 +02: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
Homu
13fe03b033 Auto merge of #635 - kbknapp:issue-634, r=kbknapp
docs: moves docs to docs.rs

Closes #634
2016-08-28 03:14:45 +09:00
Kevin K
03209d5e13 docs: moves docs to docs.rs
Closes #634
2016-08-27 11:16:35 -04:00
Homu
485d993bfd Auto merge of #631 - nabijaczleweli:feature/windows/console-wrap, r=kbknapp
Add support for wrapping help at console width on windows

Had to revert many formatting changes, which means your code is unformatted despite the presence of `rustfmt.toml` at repo root, you should global format.

Closes #455
2016-08-27 00:47:17 +09:00
nabijaczleweli
85999ea7ad
docs(app): document that Windooze supports term width detection now 2016-08-26 17:18:24 +02:00
nabijaczleweli
0d93d9b953
feat(help): support wrapping help at console width on windows
Closes #455
2016-08-26 17:18:24 +02:00
Jędrzej
853a90de01 docs(app): fix documentation formatting for App::template() (#632) 2016-08-26 11:16:32 -04:00
Homu
c95b0c62ab Auto merge of #630 - nabijaczleweli:docs/arggroup/example-2-fix, r=kbknapp
Fix ArgGroup example not formatted as code

Before:
![before image](https://cloud.githubusercontent.com/assets/6709544/18002834/a7516e88-6b8a-11e6-9212-4488e447ce61.png)

After:
![after image](https://cloud.githubusercontent.com/assets/6709544/18002850/bdc0a80a-6b8a-11e6-8887-c5cd882a0b10.png)
2016-08-26 22:44:21 +09:00
nabijaczleweli
ecfda7d434
docs(arggroup): fix example not formatted as code 2016-08-26 12:40:38 +02:00
Homu
2df109a428 Auto merge of #629 - kbknapp:issue-626, r=kbknapp
Issue 626
2016-08-26 08:45:37 +09:00
Kevin K
f7c787c1ce chore: increase version 2016-08-25 18:52:15 -04:00
Kevin K
cdb9037c15 tests: updates tests to account for variable term widths and non-english chars 2016-08-25 18:50:48 -04:00
Kevin K
d0b442c7be fix(Help Wrapping): fixes a bug where help is wrapped incorrectly and causing a panic with some non-English characters
Closes #626
2016-08-25 18:50:13 -04:00
Homu
bd704e0d4f Auto merge of #628 - kbknapp:issues-625,626, r=kbknapp
Issues 625,626
2016-08-25 11:23:26 +09:00
Kevin K
57690b2af1 chore: allows wrapping help on windows 2016-08-24 22:04:19 -04:00
Kevin K
84ad746ee5 chore: increase version 2016-08-24 21:55:01 -04:00
Kevin K
763a5c920e fix(Unicode): fixes two bugs where non-English characters were stripped or caused a panic with help wrapping
Closes #626
2016-08-24 21:50:27 -04:00
Kevin K
881a647ee9 tests: adds tests to prevent issue 626 2016-08-24 21:50:20 -04:00
Kevin K
00b8205d22 docs(Term Width): adds details about set_term_width(0) 2016-08-24 19:39:31 -04:00
Kevin K
7558261c88 tests: adds tests for ignoring term width with set_term_width(0) 2016-08-24 19:39:31 -04:00
Kevin K
7dfdaf200e feat(Help): adds new short hand way to use source formatting and ignore term width in help messages
Prior to this commit if one wished to use source formatting and ignore
term width they could do `App::set_term_width(usize::MAX)` now one can
also use `App::set_term_width(0)` which does the same thing.

Closes #625
2016-08-24 19:39:31 -04:00
Homu
0bda63a492 Auto merge of #627 - dguo:patch-1, r=kbknapp
chore: update dep

Fixes a panic when Jaro is called with strings each with a length of one. A `clap` user discovered this: dguo/strsim-rs#5
2016-08-25 08:12:26 +09:00
Danny Guo
bb23284056 chore: update dep
Fixes a panic when Jaro is called with strings each with a length of one
2016-08-23 23:19:26 -04:00
Homu
0ca6f851df Auto merge of #624 - kbknapp:issue-623, r=kbknapp
Issue 623
2016-08-22 10:11:49 +09:00
Kevin K
8ecb02d0b4 chore: increase version 2016-08-21 20:46:57 -04:00
Kevin K
a643fb283a fix: fixes a bug where the help is printed twice
Closes #623
2016-08-21 20:45:12 -04:00
Homu
b4869959c6 Auto merge of #621 - kbknapp:v2.10.1, r=kbknapp
chore: increase version
2016-08-21 13:51:29 +09:00
Kevin K
fcb049f937 chore: increase version 2016-08-20 20:11:11 -04:00
Homu
098d7faa2c Auto merge of #620 - kbknapp:issue-614, r=kbknapp
feat(YAML): allows using lists or single values with arg declarations

One can now use a list or single value for certain Arg YAML declarations
such as possible_values, etc.

Prior to this commit, if only a single value was desired one would have
to use the format:

```yaml
possible_values:
    - value
```

But now once can use

```yaml
possible_values: value
```

Closes #614
Closes #613
2016-08-21 08:33:53 +09:00
Kevin K
9ade2cd4b2 feat(YAML): allows using lists or single values with arg declarations
One can now use a list or single value for certain Arg YAML declarations
such as possible_values, etc.

Prior to this commit, if only a single value was desired one would have
to use the format:

```yaml
possible_values:
    - value
```

But now once can use

```yaml
possible_values: value
```

Closes #614
Closes #613
2016-08-20 18:59:24 -04:00
Homu
37cc3c367f Auto merge of #619 - kbknapp:issue-618, r=kbknapp
Issue 618
2016-08-21 07:13:07 +09:00
Kevin K
7bc1b4b6c7 chore: clippy run 2016-08-20 17:52:03 -04:00
Kevin K
565d21f71c chore: allows failing beta until vec_map/#20 is fixed 2016-08-20 17:52:03 -04:00
Kevin K
e203515e3a fix(Help Subcommand): fixes misleading usage string when using multi-level subcommmands
For example, doing `myprog help subcmd1 subcmd2` would have incorrectly
produced the usage string, `myprog subcmd2 [options]` but now correctly
prints `myprog subcmd1 subcmd2 [options]`

Closes #618
2016-08-20 17:17:58 -04:00
Kevin K
9e8e350b95 tests: adds tests for multi level help subcommands 2016-08-20 17:17:58 -04:00
Jesús Espino
bba598931a Fix issue #607: Remove already matched parameters on errors of required 2016-08-06 00:08:31 +02:00
Kevin K
a983bd9b7e doc: small fixes (#612) 2016-07-30 11:29:37 -04:00
Homu
8b41e94071 Auto merge of #611 - kbknapp:v2.10.0, r=kbknapp
chore: increase version
2016-07-29 11:47:18 +09:00
Kevin K
522d934b1b chore: increase version 2016-07-28 22:28:47 -04:00
Homu
3f79467e6b Auto merge of #610 - kbknapp:starkat99-fix-subcommand-name, r=kbknapp
Starkat99 fix subcommand name
2016-07-29 11:08:28 +09:00
Kevin K
32dba379d4 Merge branch 'fix-subcommand-name' of https://github.com/starkat99/clap-rs into starkat99-fix-subcommand-name 2016-07-28 21:16:09 -04:00
Tshepang Lekhonkhobe
13233d7f2f doc: small fixes (#609) 2016-07-28 21:15:10 -04:00
Homu
7d0d447ddb Auto merge of #605 - kbknapp:wdv4758h-fish-completion, r=kbknapp
Wdv4758h fish completion

merge of #579
2016-07-28 10:47:27 +09:00
Kevin K
ccdd0571c2 Merge branch 'fish-completion' of https://github.com/wdv4758h/clap-rs into wdv4758h-fish-completion 2016-07-27 21:15:39 -04:00
Kathryn Long
875df24316 fix(parser): preserve external subcommand name
BREAKING CHANGE: Access external subcommand arguments using an empty
argument name (i.e. `values_of("")`) instead of the previous subcommand
name.
2016-07-26 23:56:52 -05:00
Kathryn Long
aebc8fd828 tests(template): fix template asserts on windows 2016-07-26 23:46:06 -05:00
Chiu-Hsiang Hsu
1979d2f2f3 feat(Completions): one can generate a basic fish completions script at compile time
The following completion would happen (using example 17_yaml.rs):

```
$ prog <tab>
help subcmd
```

```
$ prog -<tab><tab>
--help  -h                            (Prints help information)
--max-vals      (you can only supply a max of 3 values for me!)
--min-vals  (you must supply at least two values to satisfy me)
--mode                   (shows an option with specific values)
--mult-vals        (demos an option which has two named values)
--option  -o                (example option argument from yaml)
--version  -V                      (Prints version information)
-F                                         (demo flag argument)
```

```
$ prog --<tab><tab>
--help  -h                            (Prints help information)
--max-vals      (you can only supply a max of 3 values for me!)
--min-vals  (you must supply at least two values to satisfy me)
--mode                   (shows an option with specific values)
--mult-vals        (demos an option which has two named values)
--option  -o                (example option argument from yaml)
--version  -V                      (Prints version information)
```

```
$ prog --mode <tab>
emacs  (shows an option with specific values)  vi  (shows an option with specific values)
```

```
$ prog subcmd -<tab>
--help  -h        (Prints help information)  -B  (example subcommand option)
--version  -V  (Prints version information)
```

```
$ prog subcmd --<tab>
--help  (Prints help information)  --version  (Prints version information)
```

Close #578
2016-07-26 10:15:37 +08:00