Commit graph

1405 commits

Author SHA1 Message Date
Jorge Aparicio
d752c17029 rename OsStrExt2::{is_empty,len} to {is_empty_,len_}
OsStr recently gained unstable inherent methods with the same name. This rename
makes sure we don't call the inherent methods but the methods provided by this
extension trait.
2016-02-21 11:18:26 -05:00
Homu
27d08bfb8d Auto merge of #425 - kbknapp:issue-421, r=kbknapp
Issue 421, 427, and 429

This PR adds better examples for `Arg` methods as well as

* implements support for displaying the help on the next line (#427)
* Clarifies `AppSettings` propagation rules (#429)
* Fixes failing clippy lints
* Moves github specific files to a `.github` directory

----

Copied from #421

- [x] `short`
- [x] `long`
- [x] `help`
- [x] `required`
- [x] `conflicts_with`
- [x] `conflicts_with_all`
- [x] `overrides_with`
- [x] `overrides_with_all`
- [x] `requires`
- [x] `requires_all`
- [x] `takes_value`
- [x] `index`
- [x] `multiple`
- [x] `global`
- [x] `empty_values`
- [x] `hidden`
- [x] `possible_values`
- [x] `possible_value`
- [x] `group`
- [x] `number_of_values`
- [x] `validator`
- [x] `max_values`
- [x] `min_values`
- [x] `use_delimiter`
- [x] `value_delimiter`
- [x] `value_names`
- [x] `value_name`
- [x] `default_value`
- [x] `next_line_help`
2016-02-19 22:27:50 +09:00
Kevin K
d0c956c1ce chore: increase version 2016-02-19 10:47:39 -05:00
Kevin K
a834ae6990 chore: hides ArgSettings in docs 2016-02-19 01:47:37 -05:00
Kevin K
3c8db0e9be docs(AppSettings): clarifies that AppSettings do not propagate
Closes #429
2016-02-19 01:47:37 -05:00
Kevin K
60c042481f chore: moves github specific files to .github dir 2016-02-19 01:47:37 -05:00
Kevin K
e2ec5f09eb chore: clippy run 2016-02-19 01:47:37 -05:00
Kevin K
6efa298cba test: fixes failing doc tests 2016-02-19 01:47:37 -05:00
Kevin K
1e79cccc12 docs(Arg Examples): adds better examples 2016-02-19 01:47:37 -05:00
Kevin K
066df7486e imp(Help): adds setting for next line help by arg
Adds a setting for both `AppSettings` and an `Arg` method which allows
placing the help text for a particular argument (or all arguments via
the `AppSettings`) on the line after the argument itself and indented
once.

This is useful for when a single argument may have a very long
invocation flag, or many value names which throws off the alignment of
al other arguments. On a small terminal this can be terrible. Placing
the text on the line below the argument solves this issue. This is also
how many of the GNU utilities display their help strings for individual
arguments.

The final caes where this can be hepful is if the argument has a very
long or detailed and complex help string that will span multiple lines.
It can be visually more appealing and easier to read when those lines
don't wrap as frequently since there is more space on the next line.

Closes #427
2016-02-17 23:47:27 -05:00
Homu
e08fdfb08a Auto merge of #423 - kbknapp:issue-418, r=kbknapp
Issue 418
2016-02-14 20:12:46 +09:00
Kevin K
b37c010c1b imp(Default Values): displays the default value in the help text 2016-02-14 01:11:06 -05:00
Kevin K
1153e8af60 chore: clippy run 2016-02-14 01:10:44 -05:00
Kevin K
33fe291b34 chore: increase version 2016-02-10 12:55:54 -05:00
Kevin K
9facd74f84 docs(Default Values): adds better examples and notes for default values 2016-02-10 12:39:44 -05:00
Kevin K
9250b1323c tests: adds tests for default values 2016-02-10 10:56:58 -05:00
Kevin K
7321195296 feat(Defult Values): adds support for default values in args
Closes #418
2016-02-10 10:56:58 -05:00
Homu
e76d75197e Auto merge of #422 - kbknapp:issue-420, r=kbknapp
Issue 420

When value names are use, they will be displayed in help and error
messages instead of the argument name. For example, an argument named
`arg` but with the value name `FILE` will be displayed as `[FILE]`.
Likewise multiple value names will be displayed properly such as `[FILE1] [FILE2]`

Closes #420
2016-02-10 04:16:28 +09:00
Kevin K
972761912a chore: increase version 2016-02-09 09:30:41 -05:00
Kevin K
5460778f56 tests: adds tests for displaying positional args with value names 2016-02-09 09:29:23 -05:00
Kevin K
f0a99916c5 imp(Positional Arguments): now displays value name if appropriate
When value names are use, they will be displayed in help and error
messages instead of the argument name. For example, an argument named
`arg` but with the value name `FILE` will be displayed as `[FILE]`.
Likewise multiple value names will be displayed properly such as `[FILE1] [FILE2]`

Closes #420
2016-02-09 09:27:17 -05:00
Homu
dfca4ea238 Auto merge of #419 - GrappigPanda:master, r=kbknapp
Grammatical pedantry

I originally set out to only change liftimes to lifetimes, but I got a little carried away.

Fear not, I decided to stop myself partially through and actually start using your library!
2016-02-06 06:04:38 +09:00
Ian C
f0f425d5a4 Update README.md 2016-02-05 14:29:10 -06:00
Ian C
f0dbb8e939 Grammatical pedantry 2016-02-05 14:15:44 -06:00
Homu
f8ecb8e693 Auto merge of #417 - kbknapp:issue-415, r=kbknapp
Issue 415

Relates to #415
2016-02-05 16:54:43 +09:00
Kevin K
26f2e5feb0 tests(Multiple Values): fixes failing benches and adds tests to guard 2016-02-04 22:15:10 -05:00
Kevin K
ea4dd195f9 chore: increase version 2016-02-04 19:45:30 -05:00
Kevin K
2ba12b8b76 tests(Multiple Values): adds test for exact number of values 2016-02-04 19:44:30 -05:00
Kevin K
72c387da0b fix(Multiple Values): fixes bug where number_of_values wasnt respected
i.e. assume, option -O set to multiple, and number_of_values(1)
set. And assume a *required* positional argument is also set.

-O some -O other pos

Would fail with pos arg not supplied.

Relates to #415
2016-02-04 19:38:17 -05:00
Homu
106a13de06 Auto merge of #414 - kbknapp:globalvers, r=kbknapp
Globalvers
2016-02-04 23:29:51 +09:00
Kevin K
ff259626f7 chore: updates changelog 2016-02-04 11:56:47 -05:00
Kevin K
4f207a1195 tests(AppSettings): adds test for GlobalVersion 2016-02-04 11:55:58 -05:00
Kevin K
a62e452754 fix(AppSettings): fixes bug where subcmds didn't receive parent ver
Subcommands now receive the parent version when the setting
AppSettings::GlobalVersion has been set.
2016-02-04 11:54:46 -05:00
Homu
990ddfbc9a Auto merge of #413 - kbknapp:v2.0.4, r=kbknapp
V2.0.4

Common 90% coverage! 🙏
2016-02-04 22:15:00 +09:00
Homu
355a5fdabd Auto merge of #411 - cite-reader:hyphen-doesnt-panic, r=kbknapp
fix: Stop lonely hyphens from causing panic

The method `starts_with` as implemented for the `OsStrExt2` trait on
`OsStr` assumed that the needle given is shorter than the haystack. When
this is not the case, the method panics due to an attempted
out-of-bounds access on the byte representation of `self`. Problematic
if, say, an end-user gives us `"-"` and the library tries to see if that
starts with `"--"`.

Fortunately, slices already implement a `starts_with` method, and we can
delegate to it.

This *does* create a semantics change: if both `self` and the needle
have length 0, this implementation will return `true`, but the old
implementation would return `false`. Based on the test suite still
passing, acknowledging the vacuous truth doesn't seem to cause any
problems.

Fixes #410
2016-02-04 16:15:31 +09:00
Kevin K
9f7a4afea6 chore: increase version 2016-02-04 02:01:10 -05:00
Kevin K
a33e3df8f5 tests: adds tests for stdin char and only positional vals follow 2016-02-04 02:01:10 -05:00
Kevin K
8bcbce27f7 tests(Suggestions): adds additional tests 2016-02-04 02:01:10 -05:00
Kevin K
7166f4f110 refactor(macros): removes ok() from Result.ok().expect() 2016-02-04 02:01:10 -05:00
Kevin K
2bc1908320 tests(ArgGroup): adds additional tests including YAML 2016-02-04 02:01:10 -05:00
Kevin K
fcbc7e12f5 fix: adds support for building ArgGroups from standalone YAML
ArgGroups can now be built from standalone YAML documents. This is
labeled as a fix because it should have been the case prior. A
standalone YAML document for a group would look something like

```
name: test
args:
    - arg1
    - arg2
required: true
conflicts:
    - arg3
requires:
    - arg4
```

This commit also keeps support building groups as part of a larger
entire App YAML document where the name is specified as a key to the
yaml tree
2016-02-04 02:01:10 -05:00
Alex Hill
85b11468b0 fix: Stop lonely hyphens from causing panic
The method `starts_with` as implemented for the `OsStrExt2` trait on
`OsStr` assumed that the needle given is shorter than the haystack. When
this is not the case, the method panics due to an attempted
out-of-bounds access on the byte representation of `self`. Problematic
if, say, an end-user gives us `"-"` and the library tries to see if that
starts with `"--"`.

Fortunately, slices already implement a `starts_with` method, and we can
delegate to it.

This *does* create a semantics change: if both `self` and the needle
have length 0, this implementation will return `true`, but the old
implementation would return `false`. Based on the test suite still
passing, acknowledging the vacuous truth doesn't seem to cause any
problems.

Fixes #410
2016-02-02 21:05:45 -08:00
Homu
e47f825e97 Auto merge of #408 - kbknapp:minor-bug, r=sru
Bug fixes, new setting, code clean up, and added support u64::max values per arg

This turned into a little more than just a quick bug fix 😜

Thanks to #409 I've piggy backed on that and added support for > 256 values as well.

There's also just a bunch of code deduping and super small macro cleanups.

After this merges I'll put out 2.0.3
2016-02-03 11:04:14 +09:00
Kevin K
c31c2fbe07 Merge branch 'master' into minor-bug 2016-02-02 15:51:44 -05:00
Homu
700db3f9b1 Auto merge of #409 - cstorey:master, r=kbknapp
Allow for more than 256 occurrences of an argument.

Hi,

I often use tools with `xargs` and the like, and it's entirely possible to end up with inhumanly long sets of parameters being passed to a command.

Without this fix, the library will panic with an arithmetic overflow in `ArgMatcher#inc_occurrence_of` when the 256th instance of the parameter is accounted for.

Thanks,
2016-02-03 05:08:36 +09:00
Ceri Storey
f86a183e32 chore: Add myself to contributors. 2016-02-02 19:32:11 +00:00
Ceri Storey
3731ddb361 fix(matched_arg): Allow for more than 256 occurrences of an argument. 2016-02-02 19:30:32 +00:00
Kevin K
dbea0e349b chore: increase version 2016-02-02 07:45:49 -05:00
Kevin K
07dfdd00ea tests(multiples): adds tests for > u8::max vals and occurrences 2016-02-02 07:45:49 -05:00
Kevin K
c19a791745 imp(values): adds support for up to u64::max values per arg 2016-02-02 07:45:49 -05:00