Commit graph

71 commits

Author SHA1 Message Date
Alex van de Sandt
928ded9d42 Revert "Remove #[macro_use] from src"
This reverts commit 7dcdfc8b231b41a46d4d7ab7ec2664d32804b4a3.

That commit caused doc tests to break, as well as issues with importing
macros in other modules. Note that the yaml example in `src/lib.rs` at
line 184 is broken and should probably be fixed.
2020-02-03 12:04:13 -05:00
Alex van de Sandt
fd6b32ff55 Remove #[macro_use] from src 2020-02-03 12:04:13 -05:00
Pavan Kumar Sunkara
c5eb08431a Apply suggestions from code review 2020-02-03 12:37:37 +01:00
Dylan DPC
a2ff3fa91b Revert " imp: Add exitcode::USAGE exit code as suggested in #1327" 2020-02-03 12:37:37 +01:00
Toothless204
ebdc0453eb
Update src/build/arg/mod.rs
make error message more descriptive

Co-Authored-By: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-02 12:19:55 +00:00
Toothless204
8b2a9928e8 added check for - 2020-02-02 11:48:35 +00:00
Pavan Kumar Sunkara
dd75cee72c fix: Clippy should pass 2020-02-01 06:48:50 +01:00
Pavan Kumar Sunkara
8e4a189ab0 fmt: Use standardized rustfmt rules 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
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
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
Dylan DPC
dd6c8e08ad use 2018 edition and minor refactors 2019-11-11 12:54:55 +01: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
Thiago Arrais
c3b7c01f54
Provide default_values mimicking default_value 2019-10-29 21:48:10 -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
Roy Ivy III
89f8cc6929 fix: add 'require_equals' support to YAML parsing 2019-06-23 11:37:22 -05: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
Erick Tryzelaar
4a20c6aaef Fix compiling with "--features yaml" 2019-06-19 16:32:52 -07:00
Erick Tryzelaar
2664703587 Fix most warnings
This patch:

* Removes unused `App::contains_long`
* Removes `std::ascii::AsciiExt` (deprecated in 1.26)
* Replaces `trim_left_matches` with `trim_start_matches` (added in 1.30)
* Adds `dyn` (added in 1.27)
* Removes unused `mkeymap::KeyType::{is_short,is_long}`
* Cleans up unused imports
2019-06-19 15:47:50 -07:00
Erick Tryzelaar
2e2616b59e Fix compiling on windows
This fixes compilation errors when building clap targetting windows with:

```
% rustup run nightly cargo check --target x86_64-pc-windows-msvc
```
2019-06-19 15:47:50 -07:00
Kevin K
46e81ca0b9
perf: only propagates to a single subcommand instead of all subcommands 2019-04-05 20:21:36 -04:00
Kevin K
958437661a
chore: clippy fixes 2019-04-05 20:21:34 -04:00
Kevin K
fcbae1574a
style: rustfmt run 2019-04-05 20:21:33 -04:00
Kevin K
573b0a9e88
chore: upgrades to 2018 edition of Rust 2019-04-05 20:21:30 -04:00
Kevin K
4cc85990fd
refactor: removed strings as an internal ID for arguments, groups, and
subcommands

This commit changes the internal ID to a u64 which will allow for
greater optimizations down the road. In addition, it lays the ground
work for allowing users to use things like enum variants as argument
keys instead of strings.

The only downside is each key needs to be hashed (the implementation
used is an FNV hasher for performance). However, the performance gains
in faster iteration, comparison, etc. should easily outweigh the single
hash of each argument.

Another benefit of if this commit is the removal of several lifetime
parameters, as it stands Arg and App now only have a single lifetime
parameter, and ArgMatches and ArgGroup have no lifetime parameter.
2019-04-05 20:21:22 -04:00
Kevin K
9399174416
perf: trims down some macro usage 2018-11-14 21:04:15 -05:00
Kevin K
2a480451d3 refactor: clippy run 2018-11-14 14:01:48 -05:00
Kevin K
20c72525d2 style: cargo fmt run 2018-11-14 12:05:06 -05:00
Kevin K
0de9e07412
Merge branch 'v3-master' into map 2018-11-13 22:07:16 -05:00
Kevin K
441f539ede
Merge pull request #1370 from andrewmiller1/yaml-mismatched-types-char
Yaml mismatched types char
2018-11-08 20:37:44 -05:00
Kevin K
3550066c88 refactor: cleans out deprecated code in prep for final beta.1 push 2018-11-08 20:34:13 -05:00
andrewmiller1
2fcf308792 fix: fixes yaml feature build 2018-11-04 18:44:28 -06:00
Kevin K
471376fdc7 imp: no longer automatically forces user to handle help just by overriding help arg 2018-10-20 22:27:31 -04:00
Kevin K
03333800fe refactor: remove code going to other crates and deprecations 2018-10-19 23:31:06 -04:00
Alena Yuryeva
1216cddb63 Fixed help benchmark 2018-09-01 20:42:31 +03:00
Kevin K
99bd101ea7
tests: fixes did_you_mean tests 2018-08-27 21:44:09 -04:00
Kevin K
3d662286bc
tests: fixes macro tests 2018-08-27 20:42:07 -04:00
Kevin K
400fafade2
tests: fixes help tests 2018-08-27 20:25:37 -04:00
Alena Yuryeva
b48ef85ece fixed unique_args tests 2018-08-11 21:32:06 +03:00
Alena Yuryeva
c501773ed3 Tests on flags passing 2018-08-11 20:34:40 +03:00
Kevin K
f4e19a3193
Merge branch 'map' of github.com:clap-rs/clap into map 2018-08-04 19:22:52 -04:00
Kevin K
4ff03096fb
fix: fixes rebase errors 2018-08-04 19:14:13 -04:00
Alena Yuryeva
87c88d6054
Arg-specific API for MKeyMap 2018-08-04 18:37:35 -04:00
Alena Yuryeva
272170e333
WIP 2018-08-04 18:32:08 -04:00