Commit graph

24 commits

Author SHA1 Message Date
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
patrick-gu
d79c59ab17 Add test for default_missing_values with value_delimiter 2021-09-18 15:47:03 -07:00
patrick-gu
90dde89ec4 Apply value_delimiter to default values 2021-09-18 15:15:25 -07:00
liudingming
6094520541 Don't show default_val in smart usage 2021-07-21 02:50:41 +08:00
ldm0
a1d4bd8488 Allow empty value by default, introduce NoEquals Error 2021-03-10 17:39:50 +00:00
ldm0
448ff95fb0 ldm0's patch 2021-03-09 19:06:44 +00:00
Steven Engler
6626365359 feat(build/arg/mod.rs): default_vals_if supports an Option as the default 2021-03-09 18:15:20 +00:00
CastilloDel
88ac1f1803 Add assertions for required and default simultaneously
Add the suggested changes

Fix test issue_1050_num_vals_and_defaults

It used a required which isn't needed for the purpose of the test.

Add tests for the default+required assertions

Add test for positional args with long or short
2020-10-24 12:10:07 +01:00
David Hewitt
94f6889116 Don't use default value when option is passed 2020-10-14 20:00:40 +01:00
CreepySkeleton
233af6e7a1 Arg::required_if => required_if_eq 2020-08-15 20:38:55 +03:00
Pavan Kumar Sunkara
7bc282dd4e Rename with_name to new for Arg & ArgGroup 2020-05-14 22:50:56 +02:00
Pavan Kumar Sunkara
b7f76d8e8d Put the test helper in tests 2020-02-04 09:51:46 +01:00
Thiago Arrais
c3b7c01f54
Provide default_values mimicking default_value 2019-10-29 21:48:10 -04:00
Kevin K
03333800fe refactor: remove code going to other crates and deprecations 2018-10-19 23:31:06 -04:00
Kevin K
53a7d72523
chore: removes warnings and commented out code 2018-08-01 23:13:32 -04:00
Corentin Henry
4f602b7e86 replace Arg::from_usage by Arg::from 2018-04-21 11:59:19 -07:00
Kevin K
1ab10275e4
style: rustfmt run 2018-01-25 12:21:17 -05:00
Kevin K
b399ee2604
tests: adds tests to ensure number_of_values and default_value can be used together 2017-10-24 12:57:04 -07:00
Benjamin Fry
bad5d19edb add env key for help msg 2017-10-05 10:47:53 -07:00
Benjamin Fry
f254807c73 WIP: add from_env option 2017-10-05 10:46:55 -07:00
Nuew
d5ef895541
api(Arg): add default_value_os
Also add related tests, and reframe `default_value` in terms of
`defualt_value_os`.
2017-04-24 15:49:59 -04:00
Kevin K
92919f5f67 Call this PR "Raid" cause it's squashin bugs! (#843)
* tests: adds tests for default values triggering conditional requirements

* fix: fixes a bug where default values should have triggered a conditional requirement but didnt

Closes #831

* tests: adds tests for missing conditional requirements in usage string of errors

* fix: fixes a bug where conditionally required args werent appearing in errors

* tests: adds tests for completion generators

* tests: adds tests for completions with binaries names that have underscores

* fix: fixes a bug where ZSH completions would panic if the binary name had an underscore in it

Closes #581

* fix: fixes bash completions for commands that have an underscore in the name

Closes #581

* chore: fix the category for crates.io

* docs(Macros): adds a warning about changing values in Cargo.toml not triggering a rebuild automatically

Closes #838

* fix(Completions): fixes a bug where global args weren't included in the generated completion scripts

Closes #841

* fix: fixes a println->debugln typo

* chore: increase version
2017-02-03 17:43:49 -05:00
Kevin K
60e1a3a02b
tests(Conditionally Required): adds tests for conditionally required args 2016-12-28 23:30:52 -05:00
Kevin K
b03eff6df5
tests(Default Values If): adds tests for the new defualt_value_if[s] methods 2016-12-28 23:21:40 -05:00