2
0
Fork 0
mirror of https://github.com/clap-rs/clap synced 2024-12-14 14:52:33 +00:00
Commit graph

663 commits

Author SHA1 Message Date
tormol
330a376a46 tests: run or compile some currently ignored doc-tests 2016-10-16 11:31:12 +02:00
Chiu-Hsiang Hsu
a61eaf8aad fix(Completions): fish completions for nested subcommands 2016-10-15 17:45:58 +08:00
tormol
5778871951 style: remove the .ok() in result.ok().expect("...")
clippy doesn't check doc-tests and `include!()`d files,
so there might bee more un-reported lint.
2016-10-05 23:16:22 +02:00
tormol
7f797e68d8 style: fix lints in code that's not compiled if the opt-out feature "color" is set 2016-10-05 23:16:22 +02:00
tormol
102fb7d2ce style: fix lints in yaml-related functions 2016-10-05 23:16:15 +02:00
Hideyuki Tanaka
8cd120c230 Fix the behavior of require_delimiter 2016-10-04 18:40:03 -04:00
tormol
a214a34529 refactor(app::Parser) Replace continue and .push() with iterator adaptors 2016-10-04 19:15:18 +02:00
tormol
9679713a30 refactor(app::Help): Use map.values() and don't do if !foo when there is an else 2016-10-04 19:14:32 +02:00
tormol
7455d73404 refactor(app::Help): Replace str.split('\n') with str.lines() 2016-10-04 19:02:17 +02:00
Salim Afiune
905d3b9777 Fix linting errors from rustc 1.14.0
The new version of rustc 1.14.0-nightly (144af3e97 2016-10-02) has new
linting warnings/errors. This commit fixes them.

Signed-off-by: Salim Afiune <afiune@chef.io>
2016-10-04 12:26:51 -04:00
Salim Afiune
40d6dac973 feat(flag_aliases): Ability to alias flags
Added same alias funtionality for flags, now you can do:
```
Arg::with_name("flg")
    .long("flag")
    .short("f")
    .alias("not_visible_flag")
    .visible_alias("awesome_v_flag")
```

Signed-off-by: Salim Afiune <afiune@chef.io>
2016-10-04 12:26:51 -04:00
Salim Afiune
e5d9760bea Added Arg::(visible_)alias(es) docs
Signed-off-by: Salim Afiune <afiune@chef.io>
2016-10-04 12:26:51 -04:00
Salim Afiune
33b5f6ef2c feat(arg_aliases): Ability to alias arguments
There are some cases where you need to have an argument to have an
alias, an example could be when you depricate one option in favor of
another one.

Now you are going to be able to alias arguments as follows:
```
Arg::with_name("opt")
    .long("opt")
    .short("o")
    .takes_value(true)
    .alias("invisible")
    .visible_alias("visible")
```

Closes 
2016-10-04 12:26:51 -04:00
tormol
fd4c0870be refactor(UsageParser tests) Use VecMap's .values() instead of .iter().map(|(_,&v)| v)
In many cases this makes the assert fit on one line, but the double references are a bit awkward.
2016-09-30 17:29:31 +02:00
tormol
42a6d232d4 refactor(UsageParser::parse) merge two ifs 2016-09-30 17:29:31 +02:00
tormol
bb1fa0d694 refactor(UsageParser) Make the functions passed to .stop_at() straightforward 2016-09-30 17:29:31 +02:00
tormol
1d6a7c6e7e fix(UsageParser): Handle non-ascii names / options.
This should also speeds up the parser (except maybe for short options).
Multi-codepoint characters still can't be used as short options, but people shouldn't non-ASCII options nyway.

Closes 
2016-09-30 17:29:23 +02:00
Nicolas Barbotte
bac417fa1c docs: typo 2016-09-20 09:47:50 +02:00
Kevin K
6b9bd215c1
docs(Default Values): adds better examples on using default values
Closes 
2016-09-18 16:01:27 -04:00
Kevin K
c81bc722eb
docs: updates the docs about removing implicit value_delimiter(true) 2016-09-18 15:24:44 -04:00
Kevin K
09d4d0a903
fix(Value Delimiters): fixes the confusion around implicitly setting value delimiters. (default is now false)
Now if one wishes to use value delimiters, they must explicitly set `Arg::use_delimiter(true)` or
`Arg::require_delimiter(true)`. No other methods implicitly set this value.

Closes 
2016-09-18 15:22:55 -04:00
Kevin K
92ac353b48
fix(Help Wrapping): fixes a regression-bug where the old {n} newline char stopped working
As of this commit, one can use the old newline character `{n}` or the new `\n`

Closes 
2016-09-12 23:19:26 -04:00
Kevin K
a9699e4d7c
fix(AllowLeadingHyphen): fixes a bug where valid args aren't recognized with this setting
Closes 
2016-09-12 21:48:50 -04:00
Kevin K
0dcfc77dae
tests(Debugging): standardizes certain debugging calls 2016-09-12 21:48:22 -04:00
Kevin K
8ffd7b827c Merge branch 'master' into issue-640 2016-09-11 13:00:04 -04:00
nabijaczleweli
945019654d
docs(appsettings): Document AppSetting::DisableVersion
Closes 
2016-09-11 10:31:35 +02:00
Kevin K
9151ef7398 feat(Help): adds ability to hide the possible values on a per argument basis
Previously one could only hide the possible values of an argument application or command wide, and
not on a per argument basis. Now one can use the `Arg::hide_possible_values(bool)` method to hide
only that arguments possible values.

Closes 
2016-09-10 23:07:15 -04:00
Kevin K
f9d17a060a docs(Value Delimiters): updates the docs for the Arg::multiple method WRT value delimiters and default settings 2016-09-10 18:23:31 -04:00
Kevin K
f9e692548e imp(Value Delimiters): changes the default value delimiter rules
Prior to this change, values were always delimited by default. This was causing issues with code
where the arg had a single value, and contained valid commas and shouldn't be delimited. This
commit changes the rules slightly so that values are not delimited by default, *unless* one of the
methods which implies multiple values was used (max_values, value_names, etc.).

This means single value args should *not* be delimited by default. If one wishes to use the old
way, they can add `Arg::use_delimiter(true)` to such code.

Closes 
2016-09-10 18:19:33 -04:00
nabijaczleweli
a43e28af85
feat(help): allow for limiting detected terminal width
Useful when, e.g., the terminal is fullscreen

Closes 
2016-09-10 21:19:35 +02:00
nabijaczleweli
a8afed7428
perf(help): fix redundant contains() checks
Addresses comments from c76785239f
2016-09-08 21:56:07 +02:00
Kevin K
2e99e22630 Merge branch 'master' into issue-617 2016-09-07 10:45:27 -04:00
Kevin K
c5a2b352ca docs(Help Wrapping): removes the verbage about using '{n}' to insert newlines in help text 2016-09-07 08:42:10 -04:00
Kevin K
c76785239f imp(Help Wrapping): clap now ignores hard newlines in help messages and properly re-aligns text, but still wraps if the term width is too small
Prior to this commit, clap would mangle help messages with hard newlines
(see ). After this commit, clap will ignore hard newlines and treat
them like an inserted newline, properly wrapping and aligning text and
then restarting it's count until the next newline should be inserted.

This commit also removes the need for using `{n}` to insert a newline in
help text, now the traditional `\n` can be used. For backwards
compatibility, the `{n}` still works.

Closes 
2016-09-07 08:38:26 -04:00
Aluísio Augusto Silva Gonçalves
b9b55a39df
imp(YAML): supports setting Arg::require_delimiter from YAML 2016-09-06 13:30:31 -03:00
Kevin K
0d503504d2 Merge branch 'master' of github.com:kbknapp/clap-rs 2016-09-05 22:12:12 -04:00
Kevin K
5658b117ae imp(Help Wrapping): makes some minor changes to when next line help is automatically used 2016-09-05 20:14:05 -04:00
Kevin K
01cae7990a imp(Help Wrapping): makes some minor changes to when next line help is automatically used 2016-09-05 19:51:14 -04:00
Kevin K
b246be1a4b style: rustfmt run 2016-09-05 17:03:45 -04:00
Kevin K
b3efc10751 fix(Settings): fixes an issue where settings weren't propogated down through grand-child subcommands
In some cases settings were only propogated down one level deep, this
commit ensures settings are propogated down through all subcommands
recursively.

Closes 
2016-09-05 17:01:22 -04:00
Kevin K
07e6e8ea31 style: rustfmt run 2016-09-05 15:29:40 -04:00
Kevin K
956965cc94 chore: clippy run 2016-09-05 15:14:47 -04:00
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
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 ()
* 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 

* 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 

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

Closes 

* 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 

* 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 

* chore: updates dep graph

Closes 

* chore: clippy run

* style: changes debug header to match other Rust projects

* chore: increase version
2016-08-27 23:42:31 -04: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 
2016-08-26 17:18:24 +02:00
Jędrzej
853a90de01 docs(app): fix documentation formatting for App::template() () 2016-08-26 11:16:32 -04:00
nabijaczleweli
ecfda7d434
docs(arggroup): fix example not formatted as code 2016-08-26 12:40:38 +02: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 
2016-08-25 18:50:13 -04:00