Commit graph

3368 commits

Author SHA1 Message Date
aspen
96b7fd454b
Forbid all unsafe code. 2020-08-20 18:38:40 -04:00
bors[bot]
8454136126
Merge #2085
2085: Don't print spaces in long help r=pksunkara a=knightpp



Co-authored-by: Danil Kondratiev <knightpp@protonmail.com>
2020-08-20 17:42:58 +00:00
Danil Kondratiev
5b07c8a780
fix spaces in long help tests 2020-08-20 17:28:40 +03:00
Danil Kondratiev
4878f7b7b1
don't print spaces in long help 2020-08-20 17:25:36 +03:00
bors[bot]
be27f41f83
Merge #2082
2082: Do not capture args meant for libtest from the integration tests r=pksunkara a=mkantor



Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-18 21:02:34 +00:00
Matt Kantor
247d823314 Do not capture args meant for libtest from integration tests.
Using `App::get_matches` from the integration tests meant that any
CLI arguments passed to libtest would also be captured by clap, often
causing the tests to fail.

For example, running `cargo test --test help -- --nocapture` would
result in several failed tests, even though `cargo test --test help`
worked fine. This was very surprising/confusing.

This commit makes the tests no longer implicitly rely on the value of
`env::args_os()`, which means developers can now provide arguments to
libtest without failures.
2020-08-18 11:50:48 -07:00
bors[bot]
1e3d53fd1f
Merge #2081
2081: Polish doc comments for App r=CreepySkeleton a=mkantor



Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-17 20:56:13 +00:00
bors[bot]
025ec3c28b
Merge #2078
2078: Unify naming cheme r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-17 20:35:05 +00:00
Matt Kantor
f6e28c5ff0 Remove doc mention of no-longer-existing from_yaml method. 2020-08-17 12:54:24 -07:00
CreepySkeleton
0cc8663db3 Fix benches 2020-08-17 22:27:50 +03:00
Matt Kantor
494fddd06e Polish doc comments for App.
- Fix some links.
- Make the punctuation consistent.
- Correct some spelling/grammar mistakes.
2020-08-17 11:00:00 -07:00
bors[bot]
91cc8031a3
Merge #2075
2075: Issue 1464 r=pksunkara a=tomjw64



Co-authored-by: tomjw64 <tom.jw64@gmail.com>
2020-08-16 20:08:12 +00:00
tomjw64
27771ceeb7 Show arguments in conflict message in reverse order of input 2020-08-16 03:47:19 -05:00
tomjw64
97149e37f5 Remove underscore prefix for build_conflict_err_usage 2020-08-16 03:42:58 -05:00
tomjw64
35f761e699 Extract extra logic to _build_conflict_err_usage 2020-08-15 17:58:47 -05:00
CreepySkeleton
f4fb9db65c cargo fmt 2020-08-16 00:29:30 +03:00
CreepySkeleton
0b2eac4da7 Fix yaml support 2020-08-15 23:42:23 +03:00
CreepySkeleton
ce3171ace5 Arg::required_unless_all => required_unless_eq_all 2020-08-15 20:38:57 +03:00
CreepySkeleton
b12102c832 Arg::required_unless -> required_unless_present 2020-08-15 20:38:56 +03:00
CreepySkeleton
55dceca819 Improve documentation 2020-08-15 20:38:56 +03:00
CreepySkeleton
233af6e7a1 Arg::required_if => required_if_eq 2020-08-15 20:38:55 +03:00
CreepySkeleton
8b85c4ecea Arg::required_ifs => required_if_eq_any 2020-08-15 20:38:12 +03:00
CreepySkeleton
6b6b6035ed Arg::required_unless_one => required_unless_eq_any 2020-08-15 20:38:11 +03:00
tomjw64
481229fffd Remove stray print 2020-08-15 04:49:53 -05:00
tomjw64
826db05319 Add test for three argument conflict output 2020-08-15 04:43:12 -05:00
tomjw64
6602feb9e6 Also include required arguments in conflict output 2020-08-15 04:17:28 -05:00
tomjw64
4372aa0fa6 Enable assertions on conflict_output_with_required 2020-08-15 04:16:23 -05:00
tomjw64
b3e523912f Add new tests for usage including required args 2020-08-15 03:20:48 -05:00
tomjw64
937e14f6e8 Remove latter conflicting arg from usage message 2020-08-15 03:17:16 -05:00
tomjw64
fbb7a0f6e4 Re-enable conflict_output and conflict_output_rev 2020-08-15 03:16:47 -05:00
bors[bot]
ddd55e57dc
Merge #2069
2069: Added opencollective sponsors to readme r=CreepySkeleton a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-08-15 00:27:41 +00:00
bors[bot]
26aa746c3a
Merge #2067
2067: Use a template to produce the default help message r=pksunkara a=mkantor



Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-14 23:42:38 +00:00
Matt Kantor
85d3daa8c1 Use a different default template when there are no args.
This eliminates extraneous empty lines when there are no user-defined
args, the default args are disabled, and `after_help` is set.
2020-08-14 14:02:52 -07:00
Matt Kantor
de6a5af1b2 Add a (failing) test for no args + after help. 2020-08-14 13:58:56 -07:00
Matt Kantor
4545a47ff6 Fix: {before-help} should have fallback just like {after-help}. 2020-08-14 13:58:37 -07:00
bors[bot]
16cf7685d7
Merge #2072
2072: Fix YAML's default_value_if handling r=pksunkara a=bkaestner



Co-authored-by: Benjamin Kästner <benjamin.kaestner@gmail.com>
2020-08-14 17:05:08 +00:00
Benjamin Kästner
15c441708b Fix YAML null value in fixture
The YAML null value is called `null` in YAML, not `Null`. yaml-rust
handles those values according to spec, so we should use the correct
capitalization.

See https://yaml.org/spec/1.2/spec.html#id2803362 for more
information.
2020-08-14 18:28:43 +02:00
Benjamin Kästner
2b101ad7e5 Properly handle YAML null macros for default_value_if
The macro `yaml_opt_str` is only used in `yaml_tuple3`, which again is
only used for `default_value_if`. Unfortunately, the current test
doesn't make sense, as a v.is_null() indicates a Yaml::Null, on wich
`as_str()` always returns `None`. Instead, the condition should be
negated, as the documentation of `default_value_if` hints:

> **NOTE:** If using YAML the values should be laid out as
> follows (`None` can be represented as `null` in YAML)

The case `$v.is_null()` should therefore lead to `None`, whereas all
other cases should be interpreted `as_str()`.
2020-08-14 18:28:43 +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
Matt Kantor
2c91800099 Restore details to doc comment for help_template. 2020-08-14 09:27:42 -07:00
Matt Kantor
afcacb0626 Apply wrapping to {author} and {about} template tags.
Previously wrapping was only applied to the {*-with-newline} variants.
2020-08-14 09:14:14 -07:00
Matt Kantor
059503e54d Make {before-help} and {after-help} template tags include padding.
Previously there were separate tags for this, {before-help-padded} and
{after-help-padded}. Those have been removed and the default ones
given their behavior.
2020-08-14 09:14:10 -07:00
Pavan Kumar Sunkara
291b52982a Added opencollective sponsors to readme 2020-08-14 16:36:39 +02:00
bors[bot]
5cf782afc0
Merge #2068
2068: Fix a typo in the bug report template r=CreepySkeleton a=mkantor



Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-14 02:09:26 +00:00
Matt Kantor
ae0ca8fd2b Fix a typo in the bug report template. 2020-08-13 18:02:30 -07:00
Matt Kantor
a87320ae88 Use a template to produce the default help message.
This makes some changes to the template system:

- Template tags for optional items (like {author}) now expand to
  nothing when the value is unset instead of a default string (like
  "unknown author").
- Many template tags now emit line-wrapped output to match
  write_default_help.
- Items with long variants now expand to the appropriate thing for -h
  vs --help.
- The now-obsolete {long-about} tag has been removed.
- A few new tags have been added.

These are externally-visible changes, but if this makes it into 3.0
that's probably reasonable?

Note that line-wrapping can have some odd edge cases since it does not
account for preceding/trailing characters on the same line as the tag.
This is already the case in master, but will affect some additional
tags with this changeset. See #2065 for details.

Closes #2002.
2020-08-13 17:52:48 -07:00
bors[bot]
ca6c84fa8a
Merge #1961
1961: V3 docs r=CreepySkeleton a=pksunkara



Co-authored-by: Kevin K <kbknapp@gmail.com>
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-08-12 14:58:09 +00:00
bors[bot]
2df656c98d
Merge #1998
1998: Relax some restrictions on validators r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-12 14:35:39 +00:00
Pavan Kumar Sunkara
c2e3b719ae Apply suggestions from code review
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-12 15:50:15 +02:00
CreepySkeleton
39fadbf7c8 Rebase 2020-08-12 16:40:19 +03:00