Commit graph

31 commits

Author SHA1 Message Date
Ed Page
7e899cd340 Revert "Deprecate Arg::help in favour of Arg::about"
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840

This is part of #16.  clap-rs/clap#1840 wasn't the right call but we
don't have time to make the decision now, so instead of having one
option and changing it in 4.0, this reverts back to clap2 behavior.
2021-11-18 12:25:49 -06:00
Ed Page
9f12bfec47 fix!: Rename ArgValue to PossibleValue
In considering potential work for #2683, I realized we might need a type to carry data for
each of the `multiple_values`.  `ArgValue` works both for that and for
possible values, so we need to come up with a better name for one or
both.  Changing `ArgValue`s name now would be ideal since its new in
clap3 and by renaming it, we can reduce churn for users.

While thinking about this, I realized I regularly get these mixed
up, so renaming `ArgValue` to `PossibleValue` I think will help clear
things up, regardless of #2683.
2021-10-19 10:10:37 -05:00
ModProg
d3f0534939 add hidden aliases to ArgValue 2021-09-26 22:46:23 +02:00
Morley, Jonathan
1d3a292d6b assert on leading and trailing whitespace 2021-09-24 12:38:15 -04:00
Roland Fredenhagen
5580e8c465
ArgValue builder (#2758)
* feat(arg_value): ArgValue can be used for possible_values

Through the ArgValue it is possible:

* `hide` possible_values from showing in completion, help and validation
* add `about` to possible_values in completion

* Resolved a few change-requests by epage

* make clippy happy

* add ArgValue::get_visible_value

* remove verbose destructering

* rename ArgValue::get_hidden to ArgValue::is_hidden

* add test for help output of hidden ArgValues

* Documentation for ArgValue

There is an issue that required to implement From<&ArgValue> for
ArgValue. We should probably find a solution without that.

* fix requested changes by epage

* fix formatting

* add deref in possible_values call to remove From<&&str>

* make clippy happy

* use copied() instad of map(|v|*v)

* Finishing up for merge, hopefully

* changes requested by pksunkara
2021-09-19 10:29:09 +00:00
Pavan Kumar Sunkara
3f94d17c71 Removed Arg::multiple 2021-06-16 07:17:11 +01:00
ldm0
886b873709 Demangle interlinking flags 2021-03-09 13:45:11 +00:00
Felix Van der Jeugt
d5c7c7d8bd
Fix clippy errors 2020-09-25 10:38:35 +02:00
Felix Van der Jeugt
a083953d3a
Suggest corrections with double quotes 2020-09-24 17:58:35 +02:00
Pavan Kumar Sunkara
7bc282dd4e Rename with_name to new for Arg & ArgGroup 2020-05-14 22:50:56 +02:00
Pavan Kumar Sunkara
070bd50b28 Finished color refactor 2020-04-16 12:51:26 +02:00
Pavan Kumar Sunkara
b7f76d8e8d Put the test helper in tests 2020-02-04 09:51:46 +01: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
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
Kevin K
20c72525d2 style: cargo fmt run 2018-11-14 12:05:06 -05:00
Kevin K
03333800fe refactor: remove code going to other crates and deprecations 2018-10-19 23:31:06 -04:00
Kevin K
94872e00a5
refactor(Arg): changes Arg::short to accept a char instead of &str
Closes #1303
2018-07-23 15:10:12 -04:00
etopiei
973022184e
Tests pass now 2018-02-12 14:39:55 -05:00
Kevin K
7ac5a5af9f tests: cleans up certain test cases litle by little 2018-01-09 10:53:20 -05:00
Kevin K
8c0cc5c386
style: rustfmt run 2017-11-28 08:57:04 -05:00
Kevin K
612ccaf14e
tests: adds tests for using possible_values with Arg::case_insensitive 2017-11-28 08:57:04 -05:00
Kevin K
80993357e1
api: Adds Arg::case_insensitive(bool) which allows matching Arg::possible_values without worrying about ASCII case
When used with `Arg::possible_values` it allows the argument value to pass validation even if
the case differs from that of the specified `possible_value`.

```rust
let m = App::new("pv")
    .arg(Arg::with_name("option")
        .long("--option")
        .takes_value(true)
        .possible_value("test123")
        .case_insensitive(true))
    .get_matches_from(vec![
        "pv", "--option", "TeSt123",
    ]);

assert!(m.value_of("option").unwrap().eq_ignore_ascii_case("test123"));
```

This setting also works when multiple values can be defined:

```rust
let m = App::new("pv")
    .arg(Arg::with_name("option")
        .short("-o")
        .long("--option")
        .takes_value(true)
        .possible_value("test123")
        .possible_value("test321")
        .multiple(true)
        .case_insensitive(true))
    .get_matches_from(vec![
        "pv", "--option", "TeSt123", "teST123", "tESt321"
    ]);

let matched_vals = m.values_of("option").unwrap().collect::<Vec<_>>();
assert_eq!(&*matched_vals, &["TeSt123", "teST123", "tESt321"]);
```

Closes #1118
2017-11-28 08:57:04 -05:00
Kevin K
f967235a90
tests: massively rehauls tests for better debugging and vastly improved error messages/deduplication 2017-01-02 23:05:50 -05:00
tormol
996fc38176 docs: fix tests that fail when the "suggestions" feature is disabled 2016-10-16 11:31:12 +02:00
Bence Szigeti
f8ca3085da Fix: typo -- missing space and commas 2016-07-05 22:14:47 +02:00
Bence Szigeti
8d7bea823f Fix: extra space typo removed 2016-07-05 22:01:04 +02:00
Kevin K
b42ca0b5ab chore(Tests): had to remove external clap-test crate...sad face 2016-05-09 22:46:09 -04:00
Kevin K
852e58156c tests: removes old python tests and replaces with rust tests
Closes #166
2016-05-09 19:14:11 -04:00
Kevin K
0031d78564 refactor(v2): improving macros for code dedup 2016-01-28 11:45:31 -05:00
Kevin K
7fc18e685f test(v2): fixing tests to pass under new v2 changes 2016-01-28 11:45:31 -05:00
Sung Rim Huh
1c41d1bf43 tests(possible_values): add tests for possible values 2016-01-13 08:52:42 -08:00