Commit graph

1546 commits

Author SHA1 Message Date
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
Homu
4e7466ccce Auto merge of #674 - afiune:afiune/arg-aliases, r=kbknapp
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 deprecate one option in favor of
another one.

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

Closes #669

Also you can alias flags as follow:
```rust
Arg::with_name("flg")
    .long("flag")
    .short("f")
    .alias("not_visible_flag")
    .visible_alias("awesome_v_flag")
```
2016-10-05 01:51:09 +09: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 #669
2016-10-04 12:26:51 -04:00
Homu
4c0ed77601 Auto merge of #670 - tormol:parse_nonascii_usage, r=kbknapp
Handle non-ascii names / options in from_usage().

Closes #664 and should make it faster too.

Why aren't the stop_at functions written like `c != a && c != b`?
2016-10-05 01:20:19 +09: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 #664
2016-09-30 17:29:23 +02:00
Homu
5c7a2190cc Auto merge of #668 - nicompte:patch-2, r=kbknapp
docs: typo
2016-09-28 00:33:23 +09:00
Nicolas Barbotte
bac417fa1c docs: typo 2016-09-20 09:47:50 +02:00
Homu
7483cec06c Auto merge of #667 - kbknapp:issues-418,666, r=kbknapp
Issues 418,666
2016-09-19 05:23:23 +09:00
Kevin K
aad171d3e1
chore: increase version 2016-09-18 16:01:27 -04:00
Kevin K
6b9bd215c1
docs(Default Values): adds better examples on using default values
Closes #418
2016-09-18 16:01:27 -04:00
Kevin K
325610eb04
docs: updates README.md with new website information and updated video tutorials info 2016-09-18 16:01:27 -04:00
Kevin K
d12649fd7b
tests: adds tests for value delimiters 2016-09-18 16:01:26 -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 #666
2016-09-18 15:22:55 -04:00
Homu
ecc6d89244 Auto merge of #662 - kbknapp:issue-661, r=kbknapp
Issue 661
2016-09-13 23:32:16 +09:00
Kevin K
44742844bc
chore: increase version 2016-09-12 23:28:12 -04:00
Kevin K
5c29448d54
tests(AllowLeadingHyphen): adds test issue 588 AllowLeadingHyphen not recognizing valid args 2016-09-12 23:26:49 -04:00
Kevin K
1ea9bef20d
test(Help Wrapping): adds tests for the old newline characters 2016-09-12 23:20:40 -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 #661
2016-09-12 23:19:26 -04:00
Homu
804a60f781 Auto merge of #660 - kbknapp:issue-588, r=kbknapp
Issue 588
2016-09-13 11:25:56 +09:00
Kevin K
fd4414768d
chore: increase version 2016-09-12 21:59:46 -04:00
Kevin K
a9699e4d7c
fix(AllowLeadingHyphen): fixes a bug where valid args aren't recognized with this setting
Closes #588
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
Homu
703b001d06 Auto merge of #658 - kbknapp:issue-640, r=kbknapp
Issue 640
2016-09-12 03:09:32 +09:00
Kevin K
8ffd7b827c Merge branch 'master' into issue-640 2016-09-11 13:00:04 -04:00
Homu
317402d9e1 Auto merge of #659 - nabijaczleweli:docs/appsettings/disableversion-doc, r=kbknapp
Document AppSetting::DisableVersion

Closes #589
2016-09-12 00:28:07 +09:00
nabijaczleweli
945019654d
docs(appsettings): Document AppSetting::DisableVersion
Closes #589
2016-09-11 10:31:35 +02:00
Kevin K
4c8ae08e4c
tests(Help): adds tests for per argument hiding of possible values 2016-09-10 23:11:43 -04: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 #640
2016-09-10 23:07:15 -04:00
Homu
82234fa93f Auto merge of #657 - kbknapp:issue-655, r=kbknapp
Issue 655
2016-09-11 11:19:41 +09: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 #655
2016-09-10 18:19:33 -04:00
Kevin K
9881a4a23a tests(Value Delimiters): updates tests to new value delimiter rules 2016-09-10 18:18:43 -04:00
Homu
3834063d10 Auto merge of #654 - nabijaczleweli:feature/help/term-width-override, r=kbknapp
Allow for limiting detected term width

Closes #653
2016-09-11 04:44:21 +09:00
nabijaczleweli
a43e28af85
feat(help): allow for limiting detected terminal width
Useful when, e.g., the terminal is fullscreen

Closes #653
2016-09-10 21:19:35 +02:00
Homu
377b5f20da Auto merge of #652 - nabijaczleweli:perf/help/remove-redundant-contains, r=kbknapp
Fix redundant contains() checks

Addresses comments on c76785239f
2016-09-09 05:58:33 +09:00
nabijaczleweli
a8afed7428
perf(help): fix redundant contains() checks
Addresses comments from c76785239f
2016-09-08 21:56:07 +02:00
Homu
59bee8413b Auto merge of #651 - kbknapp:v2.11.3, r=kbknapp
chore: increase version
2016-09-09 04:43:02 +09:00
Kevin K
aded9abdc5 chore: increase version 2016-09-07 17:40:38 -04:00
Homu
345e0e333f Auto merge of #650 - kbknapp:issue-617, r=kbknapp
Issue 617
2016-09-08 00:24:08 +09:00
Kevin K
2e99e22630 Merge branch 'master' into issue-617 2016-09-07 10:45:27 -04:00
Kevin K
934094d7c5 tests: updates tests for new help wrapping rules 2016-09-07 08:42:42 -04:00