Commit graph

1564 commits

Author SHA1 Message Date
Kevin K
edf9b2331c imp(arg_enum!): allows using meta items like repr(C) with arg_enum!s
One can now use more than one meta item, and things like `#[repr(C)]`

Example:

```rust

arg_enum! {
	#[repr(C)]
	#[derive(Debug)]
	pub enum MyEnum {
		A=1,
		B=2
	}
}

```

Closes #543
2016-06-28 00:09:25 -04:00
Homu
18237f403a Auto merge of #542 - brianp:issue-426, r=kbknapp
imp(ArgGroup): Add multiple ArgGroups per Arg

Add the function `Arg.groups` that can take a `Vec<&'a str>` to add the `Arg` to multiple `ArgGroup`'s at once.

ex:
```rust
Arg::with_name("arg")
    .groups(&["grp1", "grp2"])
```

Closes #426
2016-06-25 03:26:48 +09:00
Homu
3803b94ef0 Auto merge of #541 - hexjelly:fix-doc-typos, r=kbknapp
docs: fix typos

Just caught a couple of small typos while browsing the documentation, I believe the meaning of everything is still conveyed as intended as it's just single words.
2016-06-25 03:09:07 +09:00
Brian Pearce
902e182f7a imp(ArgGroup): Add multiple ArgGroups per Arg
Add the function `Arg.groups` that can take a `Vec<&'a str>` to add the `Arg` to multiple `ArgGroup`'s at once.

ex:
```rust
Arg::with_name("arg")
    .groups(&["grp1", "grp2"])
```

Closes #426
2016-06-24 08:57:11 -07:00
Roger Andersen
43b3d40b8c docs: fix typos 2016-06-24 12:23:08 +02:00
Homu
16c693a6db Auto merge of #540 - kbknapp:issues-536_to_539, r=kbknapp
Issues 536 to 539
2016-06-24 14:00:42 +09:00
Kevin K
e84cc01836 fix(App): using App::print_help now prints the same as would have been printed by --help or the like
Using `App::print_help` before wasn't building the default `--help` and `--version` flags properly.
This has now been fixed.

Closes #536
2016-06-24 00:32:53 -04:00
Kevin K
4f805d53e7 tests(Usage Strings): updates usage string tests 2016-06-24 00:17:04 -04:00
Kevin K
9b2e45b170 imp(Usage Strings): [FLAGS] and [ARGS] are no longer blindly added to usage strings
In usage strings `[FLAGS]` and `[ARGS]` tags are now only added if there are relevant flags and
args to collapse. I.e. those that are

 * Not required (`[ARGS]` only)
 * Not belonging to some required group
 * Excludes --help and --version (`[FLAGS]` only)

Closes #537
2016-06-24 00:15:48 -04:00
Kevin K
e3d2893f37 fix(Help): prevents invoking <cmd> help help and displaying incorrect help message
Previously, if one ran `<cmd> help help` an additional `help` subcommand was created and a help
message displayed for it. We *could* have just thrown an error `<cmd> help help` but I worry that
the message would be confusing, because something like, "Invalid Subcommand" isn't 100% correct as
the form `<cmd> help <subcmd>` is allowed, and there *is* a `help` subcmd.

This fix correct dispatches `<cmd> help help` to the `<cmd>` help message.

Closes #538
2016-06-23 23:45:32 -04:00
Kevin K
08ad1cff4f fix(Help): subcommand help messages requested via <cmd> help <sub> now correctly match <cmd> <sub> --help
Prior to this fix, runnning `prog help subcmd` would produce:

```
subcmd

USGAE:
[...]
```

Notice lack of `prog-subcmd`. Whereas running `prog subcmd --help` produced:

```
prog-subcmd

USGAE:
[...]
```

These two forms now match the correct one (latter).

Closes #539
2016-06-23 21:47:30 -04:00
Homu
89d208eb7b Auto merge of #535 - kbknapp:issues-533,534, r=kbknapp
Issues 533,534
2016-06-24 05:10:35 +09:00
Kevin K
9e5f4f5d73 docs(Groups): vastly improves ArgGroup docs by adding better examples
Closes #534
2016-06-23 12:42:41 -04:00
Kevin K
ba68caa3d1 tests(Groups): adds test for groups with multiple allowed 2016-06-23 12:42:41 -04:00
Kevin K
33689acc68 feat(Groups): one can now specify groups which require AT LEAST one of the args
Unlike the previous ArgGroups, which made all args in the group mutually exclusive, one can now use
`ArgGroup::multiple(true)` which allows using more than one arg in the group (i.e. they're not all
mutually exclusive). When combined with `ArgGroup::required(true)` this effectively says, "At least
one of the args must be used, and using morethan one is also OK."

Closes #533
2016-06-23 12:40:08 -04:00
Kevin K
ce724d8f61 Merge pull request #531 from kbknapp/issues-451,516
Issues 451,516
2016-06-14 22:07:45 -04:00
Kevin K
0dbe2ee600 chore: increase version 2016-06-13 22:18:34 -04:00
Kevin K
1f4da7676e fix(Help): App::before_help and App::after_help now correctly wrap
`before_help` and `after_help` weren't wrapping at the either the specified terminal width, or auto
determined one. That is now fixed.

Closes #516
2016-06-13 22:03:27 -04:00
Kevin K
1761dc0d27 feat(Help): allows wrapping at specified term width (Even on Windows!)
Now using `App::set_term_width` will set a wrapping width regardless of terminal size. This can
also be used when no terminal size can be determined (Such as on Windows). All help is now wrapped
at 120 if no terminal size has been specified, or can be determined.

Closes #451
2016-06-13 21:51:58 -04:00
Homu
9088ade4f3 Auto merge of #530 - kbknapp:issues-526,528,529, r=kbknapp
Issues 526,528,529
2016-06-13 13:18:04 +09:00
Kevin K
e468faf3f0 fix(YAML): adds missing YAML methods for App and Arg
Closes #528
2016-06-12 22:10:25 -04:00
Kevin K
eb7521a996 tests(Aliases): adds tests for alias help output 2016-06-12 21:52:18 -04:00
Kevin K
ca511de71f imp(Aliases): improves readability of asliases in help messages
Aliases are now displayed after the help text inside a `[aliases: als1, als2, als3]` style box.

Closes #526
Closes #529
2016-06-12 21:50:31 -04:00
Homu
50ca205e3b Auto merge of #525 - kbknapp:issues-521,522, r=kbknapp
Issues 521,522
2016-06-10 19:17:44 +09:00
Kevin K
2ff981b9be tests: adds tests for visible aliases 2016-06-09 22:50:02 -04:00
Kevin K
7b10e7f893 feat(Subcommands): adds support for visible aliases
This commit adds support for visible aliases, which function exactly like aliases except that they
also appear in the help message, using the help string of the aliased subcommand.

i.e.

```rust
App::new("myprog")
    .subcommand(SubCommand::with_name("test")
		.about("does testy things")
		.alias("invisible")
		.visible_alias("visible"));
```

When run with `myprog --help`, the output is:

```
myprog

USAGE:
	myprog [FLAGS] [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    help	        Prints this message or the help of the given subcommand(s)
    test|visible    does testy things
```

Closes #522
2016-06-09 21:55:35 -04:00
Kevin K
5354d14b51 fix(Subcommands): subcommands with aliases now display help of the aliased subcommand
Imagine subcommand `foo` had alias `bar`, running `myprog help bar` now correctly displays the help
for `foo`

Closes #521
2016-06-09 20:39:53 -04:00
Homu
e1d33f8f22 Auto merge of #524 - kbknapp:issues-511,523, r=kbknapp
Issues 511,523
2016-06-08 19:58:33 +09:00
Kevin K
d0fd55a78a chore: updates pinned nightly version for TravisCI 2016-06-08 00:14:46 -04:00
Kevin K
1bfae42eaf refactor: clippy run 2016-06-08 00:10:56 -04:00
Kevin K
fe0818b854 chore: unpins clippy version
Closes #523
2016-06-07 23:52:52 -04:00
Kevin K
cef4a9fa1f chore: deletes accidental file 2016-06-07 23:49:36 -04:00
Kevin K
785ff83a14 tests(Settings): adds tests for DontDelimitTrailingValues 2016-06-07 23:49:05 -04:00
Kevin K
fc3e0f5afd feat(Settings): adds new setting to stop delimiting values with -- or TrailingVarArg
One can now use `AppSettings::DontDelimitTrailingValues` to stop clap's default behavior of
delimiting values, even when `--` or `TrailingVarArg` is used. This is useful when passing other
flags and commands through to another program.

Closes #511
2016-06-07 23:49:05 -04:00
Kevin K
7db45f78d8 chore: removes extra debug statements 2016-06-07 23:49:05 -04:00
Kevin K
706a7c11b0 fix(Settings): fixes bug where new color settings couldn't be converted from strs 2016-06-07 23:49:05 -04:00
Homu
a77c800da7 Auto merge of #520 - kbknapp:issues-512,518,519, r=kbknapp
Issues 512,518,519
2016-06-08 10:16:16 +09:00
Kevin K
01e7dfd6c0 fix(Windows): fixes a failing windows build 2016-06-07 20:49:18 -04:00
Kevin K
0d541a2534 Merge branch 'master' into issues-512,518,519 2016-06-04 21:13:49 -04:00
Kevin K
6e7f3e0556 tests(Usage Strings): adds tests for single positional arg usage strings 2016-06-04 11:55:47 -04:00
Kevin K
ec86f2dada imp(Usage Strings): improves the default usage string when only a single positional arg is present
Instead of blindly printing `[ARGS]` when only a single positional arg is present, it will now
print `[NAME]` (or `[NAME]...` for multiple values allowed)

Closes #518
2016-06-04 11:55:47 -04:00
Kevin K
17bc17c699 tests(Settings): adds tests for global subcommands 2016-06-04 11:55:47 -04:00
Kevin K
e23418351a feat(Settings): one can now set an AppSetting which is propogated down through child subcommands
Closes #519
2016-06-04 11:55:47 -04:00
Kevin K
cd44080650 fix: fixes bug where args are printed out of order with templates 2016-06-04 11:55:47 -04:00
Kevin K
04d27ce803 chore: increase version 2016-06-04 11:55:47 -04:00
Kevin K
8f630c6a07 fix: fixes bug where one can't override version or help flags
Closes #514
2016-06-04 11:55:47 -04:00
Kevin K
9582b82789 tests: adds test to check for before_help 2016-06-04 11:55:47 -04:00
Kevin K
330e5edf04 fix: fixes issue where before_help wasn't printed 2016-06-04 11:55:47 -04:00
Kevin K
c8cc87ac10 tests: updates help tests to remove extra newline 2016-06-04 11:55:47 -04:00
Kevin K
054f8cb433 imp: removes extra newline from help output 2016-06-04 11:55:47 -04:00