Commit graph

1255 commits

Author SHA1 Message Date
Patrick Marks
4321cba5ba set the default disp_ord of App to 999. Required for display_order and DeriveDisplay to work properly 2020-04-01 12:49:40 -07:00
Mátyás Mustoha
8687794986 style: fix comma placement for valid values when using arg_enum 2020-04-01 00:01:51 +02:00
Matthias Krüger
428a075e41 remove redundant imports and clone (found by clippy) 2020-03-25 13:43:01 +01:00
bors[bot]
2aa38e81a9
Merge #1739
1739: Remove _some_ of pubs r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-03-19 23:53:18 +00:00
CreepySkeleton
a46ab1639a Turn some integration tests into unit tests 2020-03-19 10:49:49 +03:00
CreepySkeleton
4fc4a00b8f Remove _some_ of pubs 2020-03-19 10:17:52 +03:00
CreepySkeleton
b61a807728 Fix clippy and bump MSRV 2020-03-13 22:41:40 +03:00
CreepySkeleton
3e1f6ed514 Use proper cfg 2020-03-09 23:42:14 +03:00
CreepySkeleton
329bfa9895 Get rid of extra scopes 2020-03-09 21:08:15 +03:00
Julian Laubstein
c34a0fdae9 Added tests and fixed display of conflicted flags 2020-03-08 17:11:12 +01:00
Julian Laubstein
444bce2471
Fixed #1622 2020-03-08 16:39:14 +01:00
bors[bot]
19c20f7c00
Merge #1727
1727: Fix `-- subcommand` error r=pksunkara a=ldm0



Co-authored-by: Donough Liu <ldm2993593805@163.com>
2020-03-05 13:01:05 +00:00
Donough Liu
5b9f6197b1 Test added, Apply rustfmt 2020-03-05 20:02:48 +08:00
Donough Liu
79cec6a298 Fix misplaced subcommand matching failure emitter.
Only positional args follow `--`.
2020-03-05 18:38:55 +08:00
Donough Liu
bd1b73d7c8 Another Typo 2020-03-05 17:56:24 +08:00
Donough Liu
c86ac603f1 Typo 2020-03-05 17:17:07 +08:00
Pavan Kumar Sunkara
eaae1202cb Basic github action for benchmarking 2020-03-05 09:21:39 +01:00
bors[bot]
5e0898c175
Merge #1718
1718: Fix core dump with mutually `requires()` args r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-03-04 12:51:19 +00:00
CreepySkeleton
839ed2588c Fix core dump with mutually requires() args
Fixes #1643
2020-03-04 15:21:06 +03:00
Pavan Kumar Sunkara
47782cfac6 Make cargo feature additive 2020-03-01 22:55:57 +01:00
Ivan Tham
908b7aeb44 Ambiguous suggetions for InferSubcommands
Closes #1655
2020-03-01 19:36:05 +08:00
Emily
d36277b644
Fix Clap::try_parse_from documentation 2020-02-25 16:50:47 +00:00
bors[bot]
e4a7f50128
Merge #1669
1669: refactor: Rename Arg::conflicts_with_everything to Arg::exclusive (#1… r=pksunkara a=CreepySkeleton



Co-authored-by: Gregor Pfeifer <gpfeifer@dxc.com>
2020-02-22 21:58:29 +00:00
bors[bot]
28c46b5965
Merge #1697
1697: Allow replacing input on the fly r=CreepySkeleton a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-02-21 19:13:59 +00:00
Pavan Kumar Sunkara
b8851a7d5e Allow replacing input on the fly 2020-02-21 18:15:33 +01:00
Cecile Tonglet
35b918bd72 Allow missing docs on arg_enum 2020-02-21 11:39:44 +01:00
bors[bot]
cc79c432a4
Merge #1701
1701: Remove unneeded file r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-21 09:51:56 +00:00
CreepySkeleton
4fcff089ef Remove unneeded file 2020-02-21 03:28:25 +03:00
CreepySkeleton
4f13f3155c Fix warnings on nightly 2020-02-21 01:55:19 +03:00
CreepySkeleton
43acfa00f4
Implement derive traits for Box<T> 2020-02-13 18:21:01 +03:00
bors[bot]
1e7c9efc9d
Merge #1612
1612: Use about() with help() and long_about() with long_help() r=pksunkara a=TheLostLambda

I was going through the clap documentation and was under the impression that calling `help()` would call `about()` and `long_help()` would call `long_about()`, but I've actually discovered this not to be the case. Instead, the `long_about()` was always shown when it existed, rendering the output (in the about section) of programs called with `-h` and `--help` identical. Issue #1472 shows this and that is fixed here.

Note this doesn't remove the ability to use the same about in both cases: if `long_about()` is unset, then `about()` is used in both cases.

I've changed the implementation here to use `is_some()` and `unwrap()` as opposed to `if let` because it ultimately allows for less repetitive code. Ideally, I'd be able to pair `if let` with a secondary condition (namely `self.use_long`), but to my dismay, let-chains are not stabilized yet.

For a second opinion, here is the code a settled on:
```
if self.use_long && parser.meta.long_about.is_some() {
    debugln!("Help::write_default_help: writing long about");
    write_thing!(parser.meta.long_about.unwrap())
} else if parser.meta.about.is_some() {
    debugln!("Help::write_default_help: writing about");
    write_thing!(parser.meta.about.unwrap())
}
```
Here is the alternative:
```
if self.use_long {
    if let Some(about) = parser.meta.long_about {
        debugln!("Help::write_default_help: writing long about");
        write_thing!(about)
    } else if let Some(about) = parser.meta.about {
        debugln!("Help::write_default_help: writing about");
        write_thing!(about)
   }
} else {
    if let Some(about) = parser.meta.about {
        debugln!("Help::write_default_help: writing about");
        write_thing!(about)
    }
}
```

Co-authored-by: Brooks J Rady <b.j.rady@gmail.com>
2020-02-13 07:21:05 +00:00
Brooks J Rady
9cde072b61 Use about() with help() and long_about() with long_help() 2020-02-13 00:31:45 +00:00
bors[bot]
12df8cb078
Merge #1681
1681: WIP: Extract subcommands into separate trait r=pksunkara a=CreepySkeleton

Not-yet-working-but-almost-there "multiple traits" approach. More or less done, what's left is to catch some bugs and adapt tests/examples.

For the record: it took so long because of RL stuff (who would have thought?) and because [there was a detailed description of the experience I've had here, but it was deleted because it contained a lot of profanity and emotional notes]. 

As the only person alive that understands how the derive works (if you won't blow your own horn, nobody will do it for you, yeah), I'd like to made a statement: we Do need the refactoring.

Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-12 20:42:32 +00:00
CreepySkeleton
ae574df2f9
Extract subcommands into separate trait 2020-02-12 23:15:05 +03:00
bors[bot]
0660e81231
Merge #1683
1683: Added HelpRequired AppSetting r=pksunkara a=thomasfermi

Closes #1683 

There are likely some problems with my solution to this issue. I would be thankful for a review!

Co-authored-by: thomasfermi <mario.theers@gmail.com>
2020-02-10 17:47:40 +00:00
thomasfermi
f7b63c7be6 Implemented minor review findings. 2020-02-10 17:57:32 +01:00
thomasfermi
aa97a4e8aa Added test for HelpRequired setting, which checks subcommands. Fixed bug that was discovered. 2020-02-10 14:33:26 +01:00
thomasfermi
2059bf1035 Implemented review findings for pull request #1683 2020-02-10 11:04:18 +01:00
thomasfermi
91f37f9358 Deleted unnecessary code in doc comments. 2020-02-09 21:37:19 +01:00
thomasfermi
48eb6a4530 Added HelpRequired AppSetting 2020-02-09 21:05:01 +01:00
bors[bot]
ad5606b5a0
Merge #1678
1678: Refactor clap_generate r=CreepySkeleton a=pksunkara

I have copied the code from [clap_generate]( https://github.com/clap-rs/clap_generate) and refactored the structure a bit.

This new structure will allow people to write their own generators using our `Generator` trait which will contain some helpers (Still working on polishing them).

Co-authored-by: Ole Martin Ruud <barskern@outlook.com>
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-02-08 15:00:50 +00:00
Pavan Kumar Sunkara
33f47acc67 Refactor clap_generate 2020-02-07 07:52:04 +01:00
Pavan Kumar Sunkara
5b3a0dff9c Remove extern & macro_use where possible 2020-02-07 07:34:01 +01:00
thomasfermi
582e2d39f3 Fixed typo 2020-02-05 17:24:40 +01:00
bors[bot]
509ac33a20
Merge #1664
1664: Import structopt r=pksunkara a=CreepySkeleton

OK, here is about 50% of what's left to import.

`impl StructOpt for Box<impl StructOpt>` is not imported because layouts of `StructOpt` and `Clap` are too different. I'll work it out after the import is done.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/clap-rs/clap/1664)
<!-- Reviewable:end -->


Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
Co-authored-by: Cecile Tonglet <cecile.tonglet@cecton.com>
Co-authored-by: David McNeil <mcneil.david2@gmail.com>
2020-02-05 08:43:57 +00:00
bors[bot]
e7d3600128
Merge #1670
1670: Minor refactoring r=pksunkara a=CreepySkeleton

Some minor improvements. Also gets some bugs fixed

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/clap-rs/clap/1670)
<!-- Reviewable:end -->


Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-05 08:23:28 +00:00
CreepySkeleton
ffad57c776
Update src/macros.rs
Co-Authored-By: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-02-05 10:44:20 +03:00
CreepySkeleton
28605ba326 Fix macro 2020-02-05 10:17:11 +03:00
CreepySkeleton
afac737f69 Minor refactoring 2020-02-04 19:02:29 +03:00
Gregor Pfeifer
7781fd8813 refactor: Rename Arg::conflicts_with_everything to Arg::exclusive (#1583) (#1624)
https://github.com/clap-rs/clap/pull/1624#issuecomment-571372359
2020-02-04 18:02:47 +03:00