Commit graph

1239 commits

Author SHA1 Message Date
Homu
f6d1685000 Auto merge of #449 - kbknapp:issue-428-redux, r=kbknapp
Issue 428 redux
2016-03-15 20:48:13 +09:00
Kevin K
c2cc1eb846 chore: updates readme and changelog for new features 2016-03-14 22:44:34 -04:00
Kevin K
2c12757bbd feat(Help Subcommand): adds support passing additional subcommands to help subcommand
The `help` subcommand can now accept other subcommands as arguments to
display their help message. This is similar to how many other CLIs
already perform. For example:

```
$ myprog help mysubcmd
```

Would print the help message for `mysubcmd`. But even more, the `help`
subcommand accepts nested subcommands as well, i.e. a grandchild
subcommand such as

```
$ myprog help child grandchild
```

Would print the help message of `grandchild` where `grandchild` is a
subcommand of `child` and `child` is a subcommand of `myprog`.

Closes #416
2016-03-14 22:41:47 -04:00
Kevin K
031b71733c chore: fixes platform dependant libc calls 2016-03-14 08:00:11 -04:00
Kevin K
d46eaa2cd6 style: fix formatting 2016-03-14 07:53:23 -04:00
Kevin K
f1850c654e chore: shows screenshot without clicking link 2016-03-13 22:14:07 -04:00
Kevin K
387b147820 chore: increase version 2016-03-13 22:10:34 -04:00
Kevin K
675c39f8ba tests: moves app settings tests to the proper place 2016-03-13 22:07:28 -04:00
Kevin K
e428bb6d84 tests: moves some \t tabs to four spaces for consistency 2016-03-13 22:07:28 -04:00
Kevin K
e36af02666 feat(Help Message): can auto wrap and aligning help text to term width
By default `clap` now automatically wraps and aligns help strings to the
term width. i.e.

```
    -o, --option <opt>    some really long help
text that should be auto aligned but isn't righ
t now
```

Now looks like this:

```
    -o, --option <opt>    some really long help
                          text that should be
                          auto aligned but isn't
                          right now
```

The wrapping also respects words, and wraps at spaces so as to not cut
words in the middle.

This requires the `libc` dep which is enabled (by default) with the
`wrap_help` cargo feature flag.

Closes #428
2016-03-13 22:07:28 -04:00
Homu
df38346557 Auto merge of #446 - kbknapp:issue-444, r=kbknapp
Issue 444
2016-03-11 08:03:44 +09:00
Kevin K
c5c58c86b9 fix(From Usage): fixes a bug where adding empty lines werent ignored 2016-03-10 16:36:23 -05:00
Kevin K
22000a08f7 chore: changes some assertions to debug assertions 2016-03-10 16:33:39 -05:00
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