Commit graph

1126 commits

Author SHA1 Message Date
Kevin K
ad86e43334 feat(Settings): adds support for automatically deriving custom display order of args
Args and subcommands can now have their display order automatically
derived by using the setting `AppSettings::DeriveDisplayOrder` which
will display the args and subcommands in the order that they were
declared in, instead of alphabetical order which is the default.

Closes #444
2016-03-10 16:32:02 -05:00
Homu
3f26d2b107 Auto merge of #443 - kbknapp:issue-442, r=kbknapp
Issue 442
2016-03-10 11:23:39 +09:00
Kevin K
927d1da1c7 chore: ignore failing clippy build 2016-03-09 19:54:42 -05:00
Kevin K
06c729f52f chore: fixes failing nightly lint 2016-03-09 18:40:31 -05:00
Kevin K
4ff0205b85 docs(Groups): explains required ArgGroups better
Closes #439
2016-03-09 20:16:52 -05:00
Kevin K
e41a2f1bea test: fixes failing doc tests 2016-03-09 20:14:35 -05:00
Kevin K
7d2a2ed413 feat(Subcommands): adds support for custom ordering in help messages
Allows custom ordering of subcommands within the help message. Subcommands with a lower
value will be displayed first in the help message. This is helpful when one would like to
emphasise frequently used subcommands, or prioritize those towards the top of the list.
Duplicate values **are** allowed. Subcommands with duplicate display orders will be
displayed in alphabetical order.

**NOTE:** The default is 999 for all subcommands.

```rust
use clap::{App, SubCommand};
let m = App::new("cust-ord")
    .subcommand(SubCommand::with_name("alpha") // typically subcommands are grouped
                                               // alphabetically by name. Subcommands
                                               // without a display_order have a value of
                                               // 999 and are displayed alphabetically with
                                               // all other 999 subcommands
        .about("Some help and text"))
    .subcommand(SubCommand::with_name("beta")
        .display_order(1)   // In order to force this subcommand to appear *first*
                            // all we have to do is give it a value lower than 999.
                            // Any other subcommands with a value of 1 will be displayed
                            // alphabetically with this one...then 2 values, then 3, etc.
        .about("I should be first!"))
    .get_matches_from(vec![
        "cust-ord", "--help"
    ]);
```

The above example displays the following help message

```
cust-ord

USAGE:
    cust-ord [FLAGS] [OPTIONS]

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

SUBCOMMANDS:
    beta    I should be first!
    alpha   Some help and text
```

Closes #442
2016-03-09 19:43:53 -05:00
Kevin K
9803b51e79 feat(Opts and Flags): adds support for custom ordering in help messages
Allows custom ordering of args within the help message. Args with a lower value will be
displayed first in the help message. This is helpful when one would like to emphasise
frequently used args, or prioritize those towards the top of the list. Duplicate values
**are** allowed. Args with duplicate display orders will be displayed in alphabetical
order.

**NOTE:** The default is 999 for all arguments.

**NOTE:** This setting is ignored for positional arguments which are always displayed in
index order.

```rust
use clap::{App, Arg};
let m = App::new("cust-ord")
    .arg(Arg::with_name("a") // typically args are grouped by alphabetically by name
                             // Args without a display_order have a value of 999 and are
                             // displayed alphabetically with all other 999 args
        .long("long-option")
        .short("o")
        .takes_value(true)
        .help("Some help and text"))
    .arg(Arg::with_name("b")
        .long("other-option")
        .short("O")
        .takes_value(true)
        .display_order(1)   // Let's force this arg to appear *first*
                            // all we have to do is give it a value lower than 999
                            // any other args with a value of 1 would be displayed
                            // alphabetically with other 1 args. Then 2, then 3, etc.
        .help("I should be first!"))
    .get_matches_from(vec![
        "cust-ord", "--help"
    ]);
```

The above example displays the following help message

```
cust-ord

USAGE:
    cust-ord [FLAGS] [OPTIONS]

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

OPTIONS:
    -O, --other-option <b>    I should be first!
    -o, --long-option <a>     Some help and text
```
2016-03-09 19:41:43 -05:00
Homu
e2c104c8c5 Auto merge of #441 - kbknapp:vecmap-update, r=kbknapp
Update VecMap to 0.6

@alexbool

This is the new PR for your commit - no further action required, all rebasing is good!
2016-03-09 08:12:42 +09:00
Alexander Bulaev
150784ae20 Update VecMap to 0.6 2016-03-08 19:50:20 -05:00
Kevin K
87441b5f76 Merge pull request #440 from kbknapp/clippy-update
chore: clippy run
2016-03-08 16:23:48 -05:00
Kevin K
1862b7c2f4 Merge branch 'master' into clippy-update 2016-03-08 07:43:08 -05:00
Kevin K
deace34ad2 chore: clippy run 2016-03-08 10:39:43 -05:00
Kevin K
63d3d147b0 Merge pull request #438 from th4t/master
Update README.md
2016-03-08 07:42:50 -05:00
Vladislav Supalov
94c4335adc Update README.md
A tiny typo in the README.
2016-03-06 00:12:14 +01:00
Homu
ffbb534f81 Auto merge of #435 - kbknapp:v2.1.2, r=kbknapp
chore: increase version

Closes #434
2016-02-24 19:54:35 +09:00
Homu
a5ceee21b5 Auto merge of #433 - japaric:rustup, r=kbknapp
rustup: fix nightly

See details in the commits.
2016-02-24 16:13:04 +09:00
Kevin K
0b67367226 chore: increase version
Closes #434
2016-02-23 22:40:05 -05:00
Jorge Aparicio
56d14cbbb6 fix clippy warnings 2016-02-22 18:36:57 -05:00
Jorge Aparicio
6c851f4314 sprinkle #[derive(Copy)] 2016-02-21 11:45:19 -05:00
Jorge Aparicio
9a94ad8ad6 sprinkle #[allow(missing_debug_implementations)] 2016-02-21 11:44:45 -05:00
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