Commit graph

17 commits

Author SHA1 Message Date
AriusX7
448c102f4f fix: allow visible alias(es) in yaml files 2021-01-20 02:17:17 +05:30
Benjamin Kästner
8cb9a7d486 Add new "regex" feature
This commit introduces a new feature called `"regex"`. It adds a new
function `validator_regex` to `Arg` and was inspired by the discussion
in #1968. The name `validator_regex` was chosen instead of
`regex_validator` to make sure that the developer keeps in mind that
there may only be a single `Validator` on an `Arg`.

The feature can be used with YAML files, however there is no proper
pattern in `clap_app!` (yet).
2020-08-26 17:54:54 +02:00
Benjamin Kästner
8a2e9804d7 Provide tests for Arg::default_value_if
While reading the code for the yaml translation, I've noticed that
there is a bug in the macro `yaml_opt_str` as well as a wrong `null`
value in the test fixture.

These tests add the expected behaviour on the given fixture, e.g.

    prog
and
    prog <WRONG>
where `<WRONG>` is **not** `other` should yield `None` for
`"positional2"`, whereas

    prog other
should yield "something" and

    prog --flag ARBITRARY_VALUE
should yield "some". The first two tests

- default_value_if_not_triggered
- default_value_if_not_triggered_by_argument

fail, as the second positional arguments *gets set*, although its
conditions aren't fulfilled.
2020-08-14 18:28:12 +02:00
Marti Raudsepp
64ee0f8009 Add hinting of arg value types for zsh/fish completion
Adds new method/attribute `Arg::value_hint`, taking a `ValueHint` enum
as argument. The hint can denote accepted values, for example: paths,
usernames, hostnames, commands, etc.

This initial implementation supports hints for the zsh and fish
completion generators, support for other shells can be added later.
2020-08-06 22:17:31 +03:00
João Marcos
24760bc261 style: replacing yml with yaml for consistency 2020-07-20 20:58:34 -03:00
ConnorSkees
59f3e9414b allow short aliases on Arg
this implements Arg::short_alias, Arg::short_aliases,
Arg::short_visible_alias, and Arg::short_visible_aliases in addition to
adding their associated tests
2020-05-11 11:21:01 -04:00
Pavan Kumar Sunkara
b7f76d8e8d Put the test helper in tests 2020-02-04 09:51:46 +01:00
Alex van de Sandt
050bb7484a Fix formatting 2020-02-03 13:04:07 -05:00
Alex van de Sandt
1055bbe4aa Remove #[macro_use] from tests 2020-02-03 12:01:36 -05:00
Erick Tryzelaar
4a20c6aaef Fix compiling with "--features yaml" 2019-06-19 16:32:52 -07:00
Kevin K
03333800fe refactor: remove code going to other crates and deprecations 2018-10-19 23:31:06 -04:00
Alan K
eb68480b3b tests(yaml): Added future test for 2 space yaml 2018-06-22 13:50:44 +02:00
Kevin K
1ab10275e4
style: rustfmt run 2018-01-25 12:21:17 -05:00
CrazyMerlyn
6bf5bf5bee
fix(yaml): adds support for loading author info from yaml
fix(yaml): adds support for loading author info from yaml
2017-03-22 20:23:55 -04:00
Caleb Jones
c5dac3fa43 Support loading help_message and version_message from the YAML 2017-03-10 01:54:50 -05:00
Sung Rim Huh
3936b28035 tests(yaml): use scope wide attribute 2016-01-11 21:13:14 -08:00
Kevin K
86cf4c4562 feat(YAML): allows building a CLI from YAML files 2015-08-31 23:57:16 -04:00