Commit graph

1195 commits

Author SHA1 Message Date
Dylan DPC
922a531fa6
Update lib.rs 2020-02-02 02:02:10 +01:00
Pavan Kumar Sunkara
2a6005657e Apply suggestions from code review
Co-Authored-By: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-01 06:55:47 +01:00
Pavan Kumar Sunkara
dd75cee72c fix: Clippy should pass 2020-02-01 06:48:50 +01:00
Daniel Eades
d23df44e84 refactor: remove deprecated 'Error::description' method 2020-01-31 18:37:56 +01:00
Pavan Kumar Sunkara
8e4a189ab0 fmt: Use standardized rustfmt rules 2020-01-31 18:37:56 +01:00
Pavan Kumar Sunkara
c799e8d0ca chore: Updated contributing instructions and justfile 2020-01-31 18:37:56 +01:00
Daniel Gray
a1445b0f3b imp: Add exitcode::USAGE exit code as suggested in #1327
The reason to do this is described well in issue #1327. It is also a
recommendation of the Rust book itself:
https://rust-cli.github.io/book/in-depth/exit-code.html
2020-01-17 11:20:45 -04:00
Luca Bruno
f3683a9792 output: get rid of an unsafe block (#1636)
* parse: fix build in debug mode

This fixes a build failure in debug mode, as the value to be printed
does not implement Display.

* output: get rid of an unsafe block

This get rid of an unsafe block which is not necessary, and only used
when building in debug mode.
2020-01-17 19:05:18 +05:30
danieleades
af45420027 style: format code with rustfmt (#1632)
> incidentally, how do we feel about adding a rustfmt check to the CI(s)?
yes we should be doing that. you can send another pr that adds the check to the Ci
2020-01-11 23:45:46 +05:30
Jeremy Stucki
2e1acb648c Refactor mkeymap (#1618)
* refactor(mkeymap): Use iterators

* refactor(mkeymap): Implement contains method

* refactor(mkeymap): Deprecate methods

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-09 23:00:22 +05:30
Gregor Pfeifer
8b5ecf92e4 fix: Typos in Arg::conflicts_with_everything` (#1625)
Related to https://github.com/clap-rs/clap/pull/1624
2020-01-06 00:50:15 +05:30
Gregor Pfeifer
6180d42c00 feat: Add Arg::conflicts_with_everything method #1583 (#1624)
* feat: Add `Arg::conflicts_with_everything` method #1583

* fix: Typo in  src/build/arg/mod.rs

Co-Authored-By: Dylan DPC <dylan.dpc@gmail.com>

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-06 00:16:28 +05:30
xidaxmb
f402f7a113 imp(usage_parser.rs): add default value support (#1522)
Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-03 17:18:09 +05:30
dylan_DPC
1c79bb5b28 fix subcommand is private bug 2020-01-01 23:28:06 +05:30
ncaq
fc359e3c46 fixed: failed of multiple_occurrences with env (#1609)
The example code.

~~~rust
use clap::{App, Arg};

fn main() {
  let matches = App::new("My Super Program")
    .arg(
      Arg::with_name("verbose")
        .help("Sets the level of verbosity")
        .short('v')
        .long("verbose")
        .takes_value(false)
        .multiple_occurrences(true)
        .env("VERBOSE"),
    )
    .get_matches();

  match matches.occurrences_of("verbose") {
    0 => println!("0 No verbose info"),
    1 => println!("1 Some verbose info"),
    2 => println!("2 Tons of verbose info"),
    3 | _ => println!("3 >= Don't be crazy"),
  }
}
~~~

It code use multiple_occurrences with env.
But it do not work.
`env` method set require take value.

It result see under.

~~~console
% cargo run -- -v
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/foo -v`
error: The argument '--verbose <verbose>...' requires a value but none was supplied

USAGE:
    foo [OPTIONS]

For more information try --help
~~~

And, structopt or clap_derive may be create similar code.
So I am confused by structopt.

This to fix code small.
2019-12-22 23:03:23 +05:30
Mara Bos
2a2969aee4 Don't write --version output directly to stdout. (#1602)
Fixes #1390.
2019-11-26 18:39:12 +01:00
Dylan DPC
335f34bee2 fix broken CI 2019-11-11 14:28:30 +01:00
Dylan DPC
dd6c8e08ad use 2018 edition and minor refactors 2019-11-11 12:54:55 +01:00
Kevin K
750796b9ca
Merge branch 'master' into one-less-unsafe 2019-11-03 14:21:56 -05:00
Stéphane Campinas
4d69942db7
fix(Error): remove Copy trait bound by formatting both plain and colored error cause at the same time 2019-11-02 21:36:16 +01:00
Stéphane Campinas
991b839069
refactor(Error): add cause field to group_conflict error 2019-11-02 21:36:16 +01:00
Stéphane Campinas
15ad5954b0
feat(Error): add a cause field to the Error struct
The cause field is the actual error described in the message field,
however without extra information like usage.

Close #861
2019-11-02 21:36:11 +01:00
Sergey "Shnatsel" Davidoff
0a010a4371 Add comment on performance 2019-11-02 21:03:35 +01:00
Sergey "Shnatsel" Davidoff
925956d594 Do not leak a new string on every invocation of crate_authors! 2019-11-02 20:18:57 +01:00
Sergey "Shnatsel" Davidoff
0085bb7ee2 Make code actually work 2019-11-02 19:48:16 +01:00
Sergey "Shnatsel" Davidoff
63829a2a9f Drop unnecessary unsafe 2019-11-02 18:33:17 +01:00
Kevin K
269a5d2bb6
Merge pull request #1523 from shua/master
imp(macros): add subcommand expr macro
2019-10-30 20:29:52 -04:00
Luca BRUNO
d74e0646d2
app: quote field names in errors
This quotes all field names in errors. It makes easier for humans to
disambiguate common network-related cases which currently end up in
messages like "address is already in use".
2019-10-30 08:30:10 +00:00
shua
452b80d334 add subcommand expr macro 2019-10-30 00:22:05 -04:00
Brian Foley
56d182d98b
Qualify all names in bodies of exported macros with $crate::
The lack of qualification caused odd errors such as:

```
use clap;
let foo = clap::value_t!(matches.value_of("foo"),i u32).unwrap(); # OK
lot bar = clap::value_t!(matches, "bar", u32).unwrap(); # Compile fail
```

but

```
use clap::value_t;
let foo = value_t!(matches.value_of("foo"),i u32).unwrap(); # OK
lot bar = value_t!(matches, "bar", u32).unwrap(); # OK
```
2019-10-29 21:48:49 -04:00
Thiago Arrais
c3b7c01f54
Provide default_values mimicking default_value 2019-10-29 21:48:10 -04:00
Za Wilcox
fed3a8fc29
where -> were 2019-10-29 21:47:51 -04:00
Za Wilcox
14bfbd6ef4
add missing 'the' 2019-10-29 21:47:42 -04:00
Kevin K
c91d523d41
cargo clippy & rustfmt 2019-10-29 21:47:32 -04:00
Oleksii Filonenko
1e39967044
Fix some clippy lints
- Manually fix some problems
- Run 'cargo fix --clippy'

Commits taken from similar PRs open at that time:

- Replace indexmap remove with swap_remove
  Resolves #1562 and closes #1563
- Use cognitive_complexity for clippy lint
  Resolves #1564 and closes #1565
- Replace deprecated trim_left_matches with trim_start_matches
  Closes #1539

Co-authored-by: Antoine Martin <antoine97.martin@gmail.com>
Co-authored-by: Brian Foley <bpfoley@users.noreply.github.com>
2019-10-29 21:46:25 -04:00
Tobias Kunze
ed69a688ff
Fix some typos in the docs 2019-10-29 21:45:09 -04:00
demoray
7f835ed24d
use std::sync::Once::new() rather than ONCE_INIT
Updated to v3-master per discussion on #1521
2019-07-23 10:03:07 -04:00
Dylan DPC
180b6b82de
Merge pull request #1520 from nootanghimire/style/add-newline-after-printing-help
style(help): add newline after writing help
2019-07-23 12:35:19 +02:00
Nootan Ghimire
a87284020f
style(help): add newline after writing help 2019-07-17 10:44:14 +10:00
Dylan DPC
eb6276c772
Merge pull request #1514 from rharriso/pattern-arg-suggestion
Pattern arg suggestion
2019-07-04 15:33:53 +02:00
Dylan DPC
7ea767ad39
Merge pull request #1509 from jeremystucki/refactoring
Minor Refactoring
2019-07-02 09:28:41 +02:00
Ross Harrison
ebfe225af3 refactor(Parser,Errors): refactor(Parser,Errors): Update unknown_argument function to take option
Update unknown_argument function to take option
2019-07-01 11:25:46 -05:00
Ross Harrison
8d953cab08 feat(Errors): Add Pattern suggestion to Unknown Arg Error Message 2019-07-01 11:01:11 -05:00
Tyler Ruckinger
a5e3e62bef test in mkeymap does not need #[should_panic] 2019-06-25 19:51:12 -04:00
Roy Ivy III
89f8cc6929 fix: add 'require_equals' support to YAML parsing 2019-06-23 11:37:22 -05:00
Jeremy Stucki
9e10c45505
Use map instead of 'if let' 2019-06-21 09:54:19 +02:00
Jeremy Stucki
c6327bc22f
Use initialization shorthand 2019-06-21 09:06:06 +02:00
Jeremy Stucki
c5c64d48b7
Use map_or instead of match 2019-06-21 09:04:54 +02:00
Jeremy Stucki
5ff2bb4dcf
Use map instead of match on Option 2019-06-21 09:02:33 +02:00
Erick Tryzelaar
cacc23473c Remove v2 depecated features.
This patch:

* Removes the `ArgSettings::Global` variant, and replaces all
  users of it to `Arg::global(...)`. The variant itself is lifted up
  into a field on Arg. This was deprecated in clap 2.32.0.
* Removes AppFlags::PropagateGlobalValuesDown. This was deprecated in
  clap 2.27.0.
* Removes `Arg::empty_values`. This was deprecated in clap 2.30.0.
* Removes `ArgMatches::usage`. This was deprecated in clap 2.32.0.
2019-06-19 17:04:29 -07:00