2020-02-04 08:10:53 +00:00
|
|
|
mod utils;
|
2015-09-09 02:39:31 +00:00
|
|
|
|
2020-02-03 18:04:07 +00:00
|
|
|
use clap::{clap_app, App, AppSettings, Arg, ArgGroup, ArgSettings, ErrorKind};
|
2016-05-09 03:20:50 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static REQUIRE_DELIM_HELP: &str = "test 1.3
|
2017-10-12 22:11:51 +00:00
|
|
|
Kevin K.
|
|
|
|
tests stuff
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
test --fake <some>:<val>
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-f, --fake <some>:<val> some help";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static HELP: &str = "clap-test v1.4.8
|
2016-05-09 03:20:50 +00:00
|
|
|
Kevin K. <kbknapp@gmail.com>
|
|
|
|
tests clap library
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
clap-test [FLAGS] [OPTIONS] [ARGS] [SUBCOMMAND]
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
ARGS:
|
|
|
|
<positional> tests positionals
|
|
|
|
<positional2> tests positionals with exclusions
|
|
|
|
<positional3>... tests specific values [possible values: vi, emacs]
|
|
|
|
|
2016-05-09 03:20:50 +00:00
|
|
|
FLAGS:
|
|
|
|
-f, --flag tests flags
|
|
|
|
-F tests flags with exclusions
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
2018-02-12 19:52:29 +00:00
|
|
|
-O, --Option <option3> specific vals [possible values: fast, slow]
|
2016-05-09 03:20:50 +00:00
|
|
|
--long-option-2 <option2> tests long options with exclusions
|
|
|
|
--maxvals3 <maxvals>... Tests 3 max vals
|
|
|
|
--minvals2 <minvals>... Tests 2 min vals
|
2020-07-18 17:47:04 +00:00
|
|
|
--multvals <one> <two> Tests multiple values, not mult occs
|
|
|
|
--multvalsmo <one> <two> Tests multiple values, and mult occs
|
2016-05-09 03:20:50 +00:00
|
|
|
-o, --option <opt>... tests options
|
|
|
|
|
|
|
|
SUBCOMMANDS:
|
|
|
|
help Prints this message or the help of the given subcommand(s)
|
2016-05-30 09:39:54 +00:00
|
|
|
subcmd tests subcommands";
|
2016-05-09 03:20:50 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static SC_NEGATES_REQS: &str = "prog 1.0
|
2017-03-09 13:52:37 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
prog --opt <FILE> [PATH]
|
|
|
|
prog [PATH] <SUBCOMMAND>
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
ARGS:
|
|
|
|
<PATH> help
|
|
|
|
|
2017-03-09 13:52:37 +00:00
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-o, --opt <FILE> tests options
|
|
|
|
|
|
|
|
SUBCOMMANDS:
|
|
|
|
help Prints this message or the help of the given subcommand(s)
|
|
|
|
test";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ARGS_NEGATE_SC: &str = "prog 1.0
|
2017-03-09 13:52:37 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
prog [FLAGS] [OPTIONS] [PATH]
|
|
|
|
prog <SUBCOMMAND>
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
ARGS:
|
|
|
|
<PATH> help
|
|
|
|
|
2017-03-09 13:52:37 +00:00
|
|
|
FLAGS:
|
|
|
|
-f, --flag testing flags
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-o, --opt <FILE> tests options
|
|
|
|
|
|
|
|
SUBCOMMANDS:
|
|
|
|
help Prints this message or the help of the given subcommand(s)
|
|
|
|
test";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static AFTER_HELP: &str = "some text that comes before the help
|
2016-05-30 10:01:00 +00:00
|
|
|
|
|
|
|
clap-test v1.4.8
|
|
|
|
tests clap library
|
|
|
|
|
|
|
|
USAGE:
|
2016-06-24 04:17:04 +00:00
|
|
|
clap-test
|
2016-05-30 10:01:00 +00:00
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
some text that comes after the help";
|
|
|
|
|
2020-07-11 15:06:57 +00:00
|
|
|
static AFTER_LONG_HELP: &str = "some longer text that comes before the help
|
|
|
|
|
|
|
|
clap-test v1.4.8
|
|
|
|
tests clap library
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
clap-test
|
|
|
|
|
|
|
|
FLAGS:
|
2020-08-20 12:45:38 +00:00
|
|
|
-h, --help
|
2020-07-11 15:06:57 +00:00
|
|
|
Prints help information
|
|
|
|
|
2020-08-20 12:45:38 +00:00
|
|
|
-V, --version
|
2020-07-11 15:06:57 +00:00
|
|
|
Prints version information
|
|
|
|
|
|
|
|
|
|
|
|
some longer text that comes after the help";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static HIDDEN_ARGS: &str = "prog 1.0
|
2017-03-09 13:52:37 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
prog [FLAGS] [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-f, --flag testing flags
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-o, --opt <FILE> tests options";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static SC_HELP: &str = "clap-test-subcmd 0.1
|
2016-05-09 03:20:50 +00:00
|
|
|
Kevin K. <kbknapp@gmail.com>
|
|
|
|
tests subcommands
|
|
|
|
|
|
|
|
USAGE:
|
2017-01-03 04:05:23 +00:00
|
|
|
clap-test subcmd [FLAGS] [OPTIONS] [--] [scpositional]
|
2016-05-09 03:20:50 +00:00
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
ARGS:
|
|
|
|
<scpositional> tests positionals
|
|
|
|
|
2016-05-09 03:20:50 +00:00
|
|
|
FLAGS:
|
2017-01-03 04:05:23 +00:00
|
|
|
-f, --flag tests flags
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
2016-05-09 03:20:50 +00:00
|
|
|
|
|
|
|
OPTIONS:
|
2017-06-07 23:53:03 +00:00
|
|
|
-o, --option <scoption>... tests options
|
2018-03-07 11:23:20 +00:00
|
|
|
-s, --subcmdarg <subcmdarg> tests other args";
|
2016-01-13 17:03:27 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_1046_HIDDEN_SCS: &str = "prog 1.0
|
2017-09-14 17:37:13 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
prog [FLAGS] [OPTIONS] [PATH]
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
ARGS:
|
|
|
|
<PATH> some
|
|
|
|
|
2017-09-14 17:37:13 +00:00
|
|
|
FLAGS:
|
|
|
|
-f, --flag testing flags
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
2018-03-07 11:23:20 +00:00
|
|
|
-o, --opt <FILE> tests options";
|
2017-09-14 17:37:13 +00:00
|
|
|
|
2016-12-01 23:47:20 +00:00
|
|
|
// Using number_of_values(1) with multiple(true) misaligns help message
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_760: &str = "ctest 0.1
|
2016-12-01 23:47:20 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-O, --opt <opt> tests options
|
|
|
|
-o, --option <option>... tests options";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static RIPGREP_USAGE: &str = "ripgrep 0.5
|
2017-03-24 03:51:43 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
rg [OPTIONS] <pattern> [<path> ...]
|
|
|
|
rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
|
|
|
|
rg [OPTIONS] --files [<path> ...]
|
|
|
|
rg [OPTIONS] --type-list
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static MULTI_SC_HELP: &str = "ctest-subcmd-multi 0.1
|
2016-08-20 21:14:18 +00:00
|
|
|
Kevin K. <kbknapp@gmail.com>
|
|
|
|
tests subcommands
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest subcmd multi [FLAGS] [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-f, --flag tests flags
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-o, --option <scoption>... tests options";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_626_CUTOFF: &str = "ctest 0.1
|
2016-08-25 01:50:20 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
2016-09-06 00:46:18 +00:00
|
|
|
-c, --cafe <FILE> A coffeehouse, coffee shop, or café is an
|
|
|
|
establishment which primarily serves hot
|
2016-09-07 12:42:42 +00:00
|
|
|
coffee, related coffee beverages (e.g., café
|
|
|
|
latte, cappuccino, espresso), tea, and other
|
|
|
|
hot beverages. Some coffeehouses also serve
|
|
|
|
cold beverages such as iced coffee and iced
|
2017-01-08 11:51:20 +00:00
|
|
|
tea. Many cafés also serve some type of food,
|
|
|
|
such as light snacks, muffins, or pastries.";
|
2016-08-25 01:50:20 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_626_PANIC: &str = "ctest 0.1
|
2016-08-25 01:50:20 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
2016-08-28 03:42:31 +00:00
|
|
|
-c, --cafe <FILE>
|
2016-09-06 00:46:18 +00:00
|
|
|
La culture du café est très développée
|
|
|
|
dans de nombreux pays à climat chaud
|
2016-09-07 12:42:42 +00:00
|
|
|
d\'Amérique, d\'Afrique et d\'Asie, dans
|
|
|
|
des plantations qui sont cultivées pour
|
|
|
|
les marchés d\'exportation. Le café est
|
|
|
|
souvent une contribution majeure aux
|
2016-09-06 00:46:18 +00:00
|
|
|
exportations des régions productrices.";
|
2016-08-25 01:50:20 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static HIDE_POS_VALS: &str = "ctest 0.1
|
2016-09-11 03:08:40 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-c, --cafe <FILE> A coffeehouse, coffee shop, or café.
|
2018-02-12 19:52:29 +00:00
|
|
|
-p, --pos <VAL> Some vals [possible values: fast, slow]";
|
2016-09-11 03:08:40 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static FINAL_WORD_WRAPPING: &str = "ctest 0.1
|
2017-01-29 19:54:47 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help
|
|
|
|
Prints help
|
|
|
|
information
|
2020-08-11 22:20:34 +00:00
|
|
|
|
2017-01-29 19:54:47 +00:00
|
|
|
-V, --version
|
|
|
|
Prints
|
2017-01-29 10:46:23 +00:00
|
|
|
version
|
|
|
|
information";
|
2017-01-29 19:54:47 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static OLD_NEWLINE_CHARS: &str = "ctest 0.1
|
2016-09-13 03:20:40 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [FLAGS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-m Some help with some wrapping
|
|
|
|
(Defaults to something)
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static WRAPPING_NEWLINE_CHARS: &str = "ctest 0.1
|
2017-01-29 20:38:30 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [mode]
|
|
|
|
|
|
|
|
ARGS:
|
|
|
|
<mode> x, max, maximum 20 characters, contains
|
|
|
|
symbols.
|
feat: use textwrap crate for wrapping help texts
The textwrap crate uses a simpler linear-time algorithm for wrapping
the text. The current algorithm in wrap_help uses several O(n) calls
to String::insert and String::remove, which makes it potentially
quadratic in complexity.
Comparing the 05_ripgrep benchmark at commits textwrap~2 and textwrap
gives this result on my machine:
name before ns/iter after ns/iter diff ns/iter diff %
build_app_long 22,101 21,099 -1,002 -4.53%
build_app_short 22,138 21,205 -933 -4.21%
build_help_long 514,265 284,467 -229,798 -44.68%
build_help_short 85,720 85,693 -27 -0.03%
parse_clean 23,471 22,859 -612 -2.61%
parse_complex 29,535 28,919 -616 -2.09%
parse_lots 422,815 414,577 -8,238 -1.95%
As part of this commit, the wrapping_newline_chars test was updated.
The old algorithm had a subtle bug where it would break lines too
early. That is, it wrapped the text like
ARGS:
<mode> x, max, maximum 20 characters, contains
symbols.
l, long Copy-friendly,
14 characters, contains symbols.
m, med, medium Copy-friendly, 8
characters, contains symbols.";
when it should really have wrapped it like
ARGS:
<mode> x, max, maximum 20 characters, contains
symbols.
l, long Copy-friendly, 14
characters, contains symbols.
m, med, medium Copy-friendly, 8
characters, contains symbols.";
Notice how the word "14" was incorrectly moved to the next line. There
is clearly room for the word on the line with the "l, long" option
since there is room for "contains" just above it.
I'm not sure why this is, but the algorithm in textwrap handles this
case correctly.
2017-01-28 11:42:09 +00:00
|
|
|
l, long Copy-friendly, 14
|
|
|
|
characters, contains symbols.
|
2017-01-29 20:38:30 +00:00
|
|
|
m, med, medium Copy-friendly, 8
|
2018-03-07 11:23:20 +00:00
|
|
|
characters, contains symbols.
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information";
|
2016-10-20 23:37:39 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_688: &str = "ctest 0.1
|
2016-10-20 23:37:39 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
--filter <filter> Sets the filter, or sampling method, to use for interpolation when resizing the particle
|
2018-02-12 19:52:29 +00:00
|
|
|
images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic,
|
|
|
|
Gaussian, Lanczos3]";
|
2016-10-20 23:37:39 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_702: &str = "myapp 1.0
|
2016-10-24 09:56:21 +00:00
|
|
|
foo
|
|
|
|
bar
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp [OPTIONS] [--] [ARGS]
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
ARGS:
|
|
|
|
<arg1> some option
|
|
|
|
<arg2>... some option
|
|
|
|
|
2016-10-24 09:56:21 +00:00
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-l, --label <label>... a label
|
|
|
|
-o, --other <other> some other option
|
2018-03-07 11:23:20 +00:00
|
|
|
-s, --some <some> some option";
|
2016-10-24 09:56:21 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_777: &str = "A app with a crazy very long long
|
2017-01-02 21:44:40 +00:00
|
|
|
long name hahaha 1.0
|
|
|
|
Some Very Long Name and crazy long
|
|
|
|
email <email@server.com>
|
|
|
|
Show how the about text is not
|
|
|
|
wrapped
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help
|
|
|
|
Prints help information
|
2017-04-05 14:41:10 +00:00
|
|
|
|
2017-01-02 21:44:40 +00:00
|
|
|
-V, --version
|
|
|
|
Prints version
|
|
|
|
information";
|
|
|
|
|
2020-08-11 21:46:09 +00:00
|
|
|
static ISSUE_1642: &str = "prog
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
prog [FLAGS]
|
|
|
|
|
|
|
|
FLAGS:
|
2020-08-20 12:45:38 +00:00
|
|
|
--config
|
2020-08-11 21:46:09 +00:00
|
|
|
The config file used by the myprog must be in JSON format
|
|
|
|
with only valid keys and may not contain other nonsense
|
|
|
|
that cannot be read by this program. Obviously I'm going on
|
|
|
|
and on, so I'll stop now.
|
2020-08-11 22:20:34 +00:00
|
|
|
|
2020-08-20 12:45:38 +00:00
|
|
|
-h, --help
|
2020-08-11 21:46:09 +00:00
|
|
|
Prints help information
|
|
|
|
|
2020-08-20 12:45:38 +00:00
|
|
|
-V, --version
|
2020-08-11 21:46:09 +00:00
|
|
|
Prints version information";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static CUSTOM_VERSION_AND_HELP: &str = "customize 0.1
|
2017-03-10 06:01:32 +00:00
|
|
|
Nobody <odysseus@example.com>
|
|
|
|
You can customize the version and help text
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
customize
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-H, --help Print help information
|
|
|
|
-v, --version Print version information";
|
|
|
|
|
2020-04-08 20:26:05 +00:00
|
|
|
static HELP_CONFLICT: &str = "conflict
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
conflict [FLAGS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
--help Prints help information
|
|
|
|
-h
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static LAST_ARG: &str = "last 0.1
|
2017-03-11 05:17:57 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
last <TARGET> [CORPUS] [-- <ARGS>...]
|
|
|
|
|
|
|
|
ARGS:
|
|
|
|
<TARGET> some
|
|
|
|
<CORPUS> some
|
2018-03-07 11:23:20 +00:00
|
|
|
<ARGS>... some
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information";
|
2017-03-11 05:17:57 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static LAST_ARG_SC: &str = "last 0.1
|
2017-03-11 05:17:57 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
last <TARGET> [CORPUS] [-- <ARGS>...]
|
|
|
|
last <SUBCOMMAND>
|
|
|
|
|
|
|
|
ARGS:
|
|
|
|
<TARGET> some
|
|
|
|
<CORPUS> some
|
|
|
|
<ARGS>... some
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
2017-03-11 05:17:57 +00:00
|
|
|
SUBCOMMANDS:
|
|
|
|
help Prints this message or the help of the given subcommand(s)
|
|
|
|
test some";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static LAST_ARG_REQ: &str = "last 0.1
|
2017-03-11 05:17:57 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
last <TARGET> [CORPUS] -- <ARGS>...
|
|
|
|
|
|
|
|
ARGS:
|
|
|
|
<TARGET> some
|
|
|
|
<CORPUS> some
|
2018-03-07 11:23:20 +00:00
|
|
|
<ARGS>... some
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information";
|
2017-03-11 05:17:57 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static LAST_ARG_REQ_SC: &str = "last 0.1
|
2017-03-11 05:17:57 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
last <TARGET> [CORPUS] -- <ARGS>...
|
|
|
|
last <SUBCOMMAND>
|
|
|
|
|
|
|
|
ARGS:
|
|
|
|
<TARGET> some
|
|
|
|
<CORPUS> some
|
|
|
|
<ARGS>... some
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
2017-03-11 05:17:57 +00:00
|
|
|
SUBCOMMANDS:
|
|
|
|
help Prints this message or the help of the given subcommand(s)
|
|
|
|
test some";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static HIDE_DEFAULT_VAL: &str = "default 0.1
|
2017-03-22 10:14:02 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
default [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
--arg <argument> Pass an argument to the program. [default: default-argument]";
|
|
|
|
|
2020-09-23 08:45:14 +00:00
|
|
|
static ESCAPED_DEFAULT_VAL: &str = "default 0.1
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
default [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
--arg <argument> Pass an argument to the program. [default: \"\\n\"] [possible values: normal, \" \", \"\\n\", \"\\t\",
|
|
|
|
other]";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static LAST_ARG_USAGE: &str = "flamegraph 0.1
|
2017-05-06 23:52:12 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
flamegraph [FLAGS] [OPTIONS] [BINFILE] [-- <ARGS>...]
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
ARGS:
|
|
|
|
<BINFILE> The path of the binary to be profiled. for a binary.
|
|
|
|
<ARGS>... Any arguments you wish to pass to the being profiled.
|
|
|
|
|
2017-05-06 23:52:12 +00:00
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-v, --verbose Prints out more stuff.
|
2018-10-21 01:54:29 +00:00
|
|
|
-V, --version Prints version information
|
2017-05-06 23:52:12 +00:00
|
|
|
|
|
|
|
OPTIONS:
|
2017-05-11 15:17:28 +00:00
|
|
|
-f, --frequency <HERTZ> The sampling frequency.
|
2018-03-07 11:23:20 +00:00
|
|
|
-t, --timeout <SECONDS> Timeout in seconds.";
|
2017-05-06 23:52:12 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static LAST_ARG_REQ_MULT: &str = "example 1.0
|
2017-05-07 00:18:11 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
example <FIRST>... [--] <SECOND>...
|
|
|
|
|
|
|
|
ARGS:
|
|
|
|
<FIRST>... First
|
2018-03-07 11:23:20 +00:00
|
|
|
<SECOND>... Second
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information";
|
2017-05-07 00:18:11 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static DEFAULT_HELP: &str = "ctest 1.0
|
2017-09-06 23:19:08 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static LONG_ABOUT: &str = "myapp 1.0
|
2017-09-13 18:41:49 +00:00
|
|
|
foo
|
|
|
|
something really really long, with
|
|
|
|
multiple lines of text
|
|
|
|
that should be displayed
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp [arg1]
|
|
|
|
|
2018-03-07 11:23:20 +00:00
|
|
|
ARGS:
|
2020-08-20 12:45:38 +00:00
|
|
|
<arg1>
|
2018-03-07 11:23:20 +00:00
|
|
|
some option
|
|
|
|
|
2017-09-13 18:41:49 +00:00
|
|
|
FLAGS:
|
2020-08-20 12:45:38 +00:00
|
|
|
-h, --help
|
2017-09-13 18:41:49 +00:00
|
|
|
Prints help information
|
|
|
|
|
2020-08-20 12:45:38 +00:00
|
|
|
-V, --version
|
2018-03-07 11:23:20 +00:00
|
|
|
Prints version information";
|
2017-11-22 09:09:51 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static HIDE_ENV_VALS: &str = "ctest 0.1
|
2017-12-02 19:21:30 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-c, --cafe <FILE> A coffeehouse, coffee shop, or café. [env: ENVVAR]
|
2018-02-12 19:52:29 +00:00
|
|
|
-p, --pos <VAL> Some vals [possible values: fast, slow]";
|
2017-12-02 19:21:30 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static SHOW_ENV_VALS: &str = "ctest 0.1
|
2017-12-02 19:21:30 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest [OPTIONS]
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-c, --cafe <FILE> A coffeehouse, coffee shop, or café. [env: ENVVAR=MYVAL]
|
2018-02-12 19:52:29 +00:00
|
|
|
-p, --pos <VAL> Some vals [possible values: fast, slow]";
|
2017-12-02 19:21:30 +00:00
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static CUSTOM_HELP_SECTION: &str = "blorp 1.4
|
2018-04-04 03:27:57 +00:00
|
|
|
Will M.
|
|
|
|
does stuff
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
test --fake <some>:<val>
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-f, --fake <some>:<val> some help
|
|
|
|
|
|
|
|
NETWORKING:
|
|
|
|
-n, --no-proxy Do not use system proxy settings";
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_1487: &str = "test
|
2019-06-25 23:02:53 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest <arg1|arg2>
|
|
|
|
|
|
|
|
ARGS:
|
|
|
|
<arg1>
|
|
|
|
<arg2>
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
2019-06-25 23:51:12 +00:00
|
|
|
-V, --version Prints version information";
|
2019-06-25 23:02:53 +00:00
|
|
|
|
2020-04-16 15:21:41 +00:00
|
|
|
static ISSUE_1364: &str = "demo
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
demo [FLAGS] [OPTIONS] [FILES]...
|
|
|
|
|
|
|
|
ARGS:
|
|
|
|
<FILES>...
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-f
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
2019-04-05 02:06:23 +00:00
|
|
|
fn setup() -> App<'static> {
|
2017-11-22 09:09:51 +00:00
|
|
|
App::new("test")
|
2016-01-13 17:03:27 +00:00
|
|
|
.author("Kevin K.")
|
|
|
|
.about("tests stuff")
|
|
|
|
.version("1.3")
|
2017-11-22 09:09:51 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 18:50:17 +00:00
|
|
|
fn empty_args() -> impl IntoIterator<Item = String> {
|
|
|
|
std::iter::empty()
|
|
|
|
}
|
|
|
|
|
2017-11-22 09:09:51 +00:00
|
|
|
#[test]
|
|
|
|
fn help_short() {
|
2018-10-19 20:42:13 +00:00
|
|
|
let m = setup().try_get_matches_from(vec!["myprog", "-h"]);
|
2016-01-13 17:03:27 +00:00
|
|
|
|
|
|
|
assert!(m.is_err());
|
2020-07-20 01:27:07 +00:00
|
|
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
2016-01-13 17:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_long() {
|
2018-10-19 20:42:13 +00:00
|
|
|
let m = setup().try_get_matches_from(vec!["myprog", "--help"]);
|
2016-01-13 17:03:27 +00:00
|
|
|
|
|
|
|
assert!(m.is_err());
|
2020-07-20 01:27:07 +00:00
|
|
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
2016-01-13 17:03:27 +00:00
|
|
|
}
|
2015-09-09 02:39:31 +00:00
|
|
|
|
2016-01-15 04:23:50 +00:00
|
|
|
#[test]
|
|
|
|
fn help_no_subcommand() {
|
2018-10-19 20:42:13 +00:00
|
|
|
let m = setup().try_get_matches_from(vec!["myprog", "help"]);
|
2016-01-15 04:23:50 +00:00
|
|
|
|
|
|
|
assert!(m.is_err());
|
2016-01-21 06:48:30 +00:00
|
|
|
assert_eq!(m.unwrap_err().kind, ErrorKind::UnknownArgument);
|
2016-01-15 04:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_subcommand() {
|
2017-11-22 09:09:51 +00:00
|
|
|
let m = setup()
|
2018-01-25 04:05:05 +00:00
|
|
|
.subcommand(
|
2018-10-19 20:42:13 +00:00
|
|
|
App::new("test")
|
2018-01-25 04:05:05 +00:00
|
|
|
.about("tests things")
|
2018-10-19 20:42:13 +00:00
|
|
|
.arg("-v --verbose 'with verbosity'"),
|
2018-01-25 04:05:05 +00:00
|
|
|
)
|
2018-10-19 20:42:13 +00:00
|
|
|
.try_get_matches_from(vec!["myprog", "help"]);
|
2016-01-15 04:23:50 +00:00
|
|
|
|
|
|
|
assert!(m.is_err());
|
2020-07-20 01:27:07 +00:00
|
|
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
2016-01-15 04:23:50 +00:00
|
|
|
}
|
2017-11-22 09:09:51 +00:00
|
|
|
|
2017-05-07 00:18:11 +00:00
|
|
|
#[test]
|
|
|
|
fn req_last_arg_usage() {
|
|
|
|
let app = clap_app!(example =>
|
|
|
|
(version: "1.0")
|
|
|
|
(@arg FIRST: ... * "First")
|
|
|
|
(@arg SECOND: ... * +last "Second")
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"example --help",
|
|
|
|
LAST_ARG_REQ_MULT,
|
|
|
|
false
|
|
|
|
));
|
2017-05-07 00:18:11 +00:00
|
|
|
}
|
2016-01-15 04:23:50 +00:00
|
|
|
|
2017-05-06 23:52:12 +00:00
|
|
|
#[test]
|
|
|
|
fn args_with_last_usage() {
|
|
|
|
let app = App::new("flamegraph")
|
|
|
|
.version("0.1")
|
|
|
|
.setting(AppSettings::TrailingVarArg)
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("verbose")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Prints out more stuff.")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('v')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("verbose")
|
2018-01-31 20:15:01 +00:00
|
|
|
.setting(ArgSettings::MultipleOccurrences),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("timeout")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Timeout in seconds.")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('t')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("timeout")
|
2018-01-31 20:15:01 +00:00
|
|
|
.value_name("SECONDS"),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("frequency")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("The sampling frequency.")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('f')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("frequency")
|
2018-01-31 20:15:01 +00:00
|
|
|
.value_name("HERTZ"),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("binary path")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("The path of the binary to be profiled. for a binary.")
|
2018-01-25 04:05:05 +00:00
|
|
|
.value_name("BINFILE"),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("pass through args")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Any arguments you wish to pass to the being profiled.")
|
2018-01-31 20:15:01 +00:00
|
|
|
.settings(&[
|
|
|
|
ArgSettings::MultipleValues,
|
|
|
|
ArgSettings::MultipleOccurrences,
|
|
|
|
ArgSettings::Last,
|
2018-11-14 17:05:06 +00:00
|
|
|
])
|
|
|
|
.value_name("ARGS"),
|
2017-05-06 23:52:12 +00:00
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"flamegraph --help",
|
|
|
|
LAST_ARG_USAGE,
|
|
|
|
false
|
|
|
|
));
|
2017-05-06 23:52:12 +00:00
|
|
|
}
|
|
|
|
|
2015-09-09 02:39:31 +00:00
|
|
|
#[test]
|
2016-05-09 03:20:50 +00:00
|
|
|
fn subcommand_short_help() {
|
2020-02-04 08:10:53 +00:00
|
|
|
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "-h"]);
|
2015-09-09 02:39:31 +00:00
|
|
|
|
2016-05-09 03:20:50 +00:00
|
|
|
assert!(m.is_err());
|
2020-07-20 01:27:07 +00:00
|
|
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
2016-05-09 03:20:50 +00:00
|
|
|
}
|
2015-09-09 02:39:31 +00:00
|
|
|
|
2016-05-09 03:20:50 +00:00
|
|
|
#[test]
|
|
|
|
fn subcommand_long_help() {
|
2020-02-04 08:10:53 +00:00
|
|
|
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "--help"]);
|
2015-09-09 02:39:31 +00:00
|
|
|
|
2016-05-09 03:20:50 +00:00
|
|
|
assert!(m.is_err());
|
2020-07-20 01:27:07 +00:00
|
|
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
2016-05-09 03:20:50 +00:00
|
|
|
}
|
2015-09-09 02:39:31 +00:00
|
|
|
|
2016-05-09 03:20:50 +00:00
|
|
|
#[test]
|
|
|
|
fn subcommand_help_rev() {
|
2020-02-04 08:10:53 +00:00
|
|
|
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "help", "subcmd"]);
|
2016-05-09 03:20:50 +00:00
|
|
|
|
|
|
|
assert!(m.is_err());
|
2020-07-20 01:27:07 +00:00
|
|
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
2015-09-09 02:39:31 +00:00
|
|
|
}
|
2016-02-02 08:13:43 +00:00
|
|
|
|
|
|
|
#[test]
|
2016-05-09 03:20:50 +00:00
|
|
|
fn complex_help_output() {
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
utils::complex_app(),
|
2018-01-25 04:05:05 +00:00
|
|
|
"clap-test --help",
|
|
|
|
HELP,
|
|
|
|
false
|
|
|
|
));
|
2016-05-09 03:20:50 +00:00
|
|
|
}
|
2016-02-02 08:13:43 +00:00
|
|
|
|
2016-05-30 10:01:00 +00:00
|
|
|
#[test]
|
|
|
|
fn after_and_before_help_output() {
|
|
|
|
let app = App::new("clap-test")
|
|
|
|
.version("v1.4.8")
|
|
|
|
.about("tests clap library")
|
|
|
|
.before_help("some text that comes before the help")
|
|
|
|
.after_help("some text that comes after the help");
|
2020-07-11 15:06:57 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app.clone(),
|
|
|
|
"clap-test -h",
|
|
|
|
AFTER_HELP,
|
|
|
|
false
|
|
|
|
));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"clap-test --help",
|
|
|
|
AFTER_HELP,
|
|
|
|
false
|
|
|
|
));
|
2016-05-30 10:01:00 +00:00
|
|
|
}
|
|
|
|
|
2020-07-11 15:06:57 +00:00
|
|
|
#[test]
|
|
|
|
fn after_and_before_long_help_output() {
|
|
|
|
let app = App::new("clap-test")
|
|
|
|
.version("v1.4.8")
|
|
|
|
.about("tests clap library")
|
|
|
|
.before_help("some text that comes before the help")
|
|
|
|
.after_help("some text that comes after the help")
|
|
|
|
.before_long_help("some longer text that comes before the help")
|
|
|
|
.after_long_help("some longer text that comes after the help");
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app.clone(),
|
|
|
|
"clap-test --help",
|
|
|
|
AFTER_LONG_HELP,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"clap-test -h",
|
|
|
|
AFTER_HELP,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2016-08-20 21:14:18 +00:00
|
|
|
#[test]
|
|
|
|
fn multi_level_sc_help() {
|
2018-01-25 04:05:05 +00:00
|
|
|
let app = App::new("ctest").subcommand(
|
2018-10-19 20:42:13 +00:00
|
|
|
App::new("subcmd").subcommand(
|
|
|
|
App::new("multi")
|
2018-01-25 04:05:05 +00:00
|
|
|
.about("tests subcommands")
|
|
|
|
.author("Kevin K. <kbknapp@gmail.com>")
|
|
|
|
.version("0.1")
|
2018-10-19 20:42:13 +00:00
|
|
|
.arg("-f, --flag 'tests flags'")
|
2018-11-14 17:05:06 +00:00
|
|
|
.arg("-o, --option [scoption]... 'tests options'"),
|
2018-01-25 04:05:05 +00:00
|
|
|
),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest help subcmd multi",
|
|
|
|
MULTI_SC_HELP,
|
|
|
|
false
|
|
|
|
));
|
2016-08-20 21:14:18 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 23:35:16 +00:00
|
|
|
#[test]
|
|
|
|
fn no_wrap_help() {
|
2020-05-18 07:51:36 +00:00
|
|
|
let app = App::new("ctest").term_width(0).override_help(MULTI_SC_HELP);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
MULTI_SC_HELP,
|
|
|
|
false
|
|
|
|
));
|
2016-08-24 23:35:16 +00:00
|
|
|
}
|
|
|
|
|
2017-09-06 23:19:08 +00:00
|
|
|
#[test]
|
|
|
|
fn no_wrap_default_help() {
|
2020-05-18 07:51:36 +00:00
|
|
|
let app = App::new("ctest").version("1.0").term_width(0);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
DEFAULT_HELP,
|
|
|
|
false
|
|
|
|
));
|
2017-09-06 23:19:08 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 03:20:50 +00:00
|
|
|
#[test]
|
|
|
|
fn complex_subcommand_help_output() {
|
2020-02-04 08:10:53 +00:00
|
|
|
let a = utils::complex_app();
|
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
a,
|
|
|
|
"clap-test subcmd --help",
|
|
|
|
SC_HELP,
|
|
|
|
false
|
|
|
|
));
|
2016-02-02 08:13:43 +00:00
|
|
|
}
|
2016-08-25 01:50:20 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_626_unicode_cutoff() {
|
2020-05-18 07:51:36 +00:00
|
|
|
let app = App::new("ctest").version("0.1").term_width(70).arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("cafe")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('c')
|
2017-02-21 04:51:20 +00:00
|
|
|
.long("cafe")
|
|
|
|
.value_name("FILE")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about(
|
2018-01-25 04:05:05 +00:00
|
|
|
"A coffeehouse, coffee shop, or café is an establishment \
|
|
|
|
which primarily serves hot coffee, related coffee beverages \
|
|
|
|
(e.g., café latte, cappuccino, espresso), tea, and other hot \
|
|
|
|
beverages. Some coffeehouses also serve cold beverages such as \
|
|
|
|
iced coffee and iced tea. Many cafés also serve some type of \
|
|
|
|
food, such as light snacks, muffins, or pastries.",
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.takes_value(true),
|
2018-01-25 04:05:05 +00:00
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
ISSUE_626_CUTOFF,
|
|
|
|
false
|
|
|
|
));
|
2016-08-25 01:50:20 +00:00
|
|
|
}
|
|
|
|
|
2016-09-11 03:08:40 +00:00
|
|
|
#[test]
|
|
|
|
fn hide_possible_vals() {
|
|
|
|
let app = App::new("ctest")
|
|
|
|
.version("0.1")
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("pos")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('p')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("pos")
|
|
|
|
.value_name("VAL")
|
|
|
|
.possible_values(&["fast", "slow"])
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Some vals")
|
2018-01-25 04:05:05 +00:00
|
|
|
.takes_value(true),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("cafe")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('c')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("cafe")
|
|
|
|
.value_name("FILE")
|
|
|
|
.hide_possible_values(true)
|
|
|
|
.possible_values(&["fast", "slow"])
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("A coffeehouse, coffee shop, or café.")
|
2018-01-25 04:05:05 +00:00
|
|
|
.takes_value(true),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
HIDE_POS_VALS,
|
|
|
|
false
|
|
|
|
));
|
2016-09-11 03:08:40 +00:00
|
|
|
}
|
|
|
|
|
2016-08-25 01:50:20 +00:00
|
|
|
#[test]
|
|
|
|
fn issue_626_panic() {
|
|
|
|
let app = App::new("ctest")
|
|
|
|
.version("0.1")
|
2020-05-18 07:51:36 +00:00
|
|
|
.term_width(52)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("cafe")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('c')
|
2016-08-25 01:50:20 +00:00
|
|
|
.long("cafe")
|
|
|
|
.value_name("FILE")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("La culture du café est très développée dans de nombreux pays à climat chaud d'Amérique, \
|
2016-08-25 01:50:20 +00:00
|
|
|
d'Afrique et d'Asie, dans des plantations qui sont cultivées pour les marchés d'exportation. \
|
|
|
|
Le café est souvent une contribution majeure aux exportations des régions productrices.")
|
|
|
|
.takes_value(true));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
ISSUE_626_PANIC,
|
|
|
|
false
|
|
|
|
));
|
2016-08-25 01:50:20 +00:00
|
|
|
}
|
2016-08-25 22:50:48 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_626_variable_panic() {
|
|
|
|
for i in 10..320 {
|
|
|
|
let _ = App::new("ctest")
|
|
|
|
.version("0.1")
|
2020-05-18 07:51:36 +00:00
|
|
|
.term_width(i)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("cafe")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('c')
|
2016-08-25 22:50:48 +00:00
|
|
|
.long("cafe")
|
|
|
|
.value_name("FILE")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("La culture du café est très développée dans de nombreux pays à climat chaud d'Amérique, \
|
2016-08-25 22:50:48 +00:00
|
|
|
d'Afrique et d'Asie, dans des plantations qui sont cultivées pour les marchés d'exportation. \
|
|
|
|
Le café est souvent une contribution majeure aux exportations des régions productrices.")
|
|
|
|
.takes_value(true))
|
2018-10-19 20:42:13 +00:00
|
|
|
.try_get_matches_from(vec!["ctest", "--help"]);
|
2016-08-25 22:50:48 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-13 03:20:40 +00:00
|
|
|
|
2017-01-29 19:54:47 +00:00
|
|
|
#[test]
|
|
|
|
fn final_word_wrapping() {
|
2020-05-18 07:51:36 +00:00
|
|
|
let app = App::new("ctest").version("0.1").term_width(24);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
FINAL_WORD_WRAPPING,
|
|
|
|
false
|
|
|
|
));
|
2017-01-29 19:54:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 20:38:30 +00:00
|
|
|
#[test]
|
|
|
|
fn wrapping_newline_chars() {
|
2020-05-14 20:50:56 +00:00
|
|
|
let app = App::new("ctest")
|
|
|
|
.version("0.1")
|
2020-05-18 07:51:36 +00:00
|
|
|
.term_width(60)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("mode").about(
|
|
|
|
"x, max, maximum 20 characters, contains symbols.\n\
|
2020-04-12 01:36:20 +00:00
|
|
|
l, long Copy-friendly, 14 characters, contains symbols.\n\
|
|
|
|
m, med, medium Copy-friendly, 8 characters, contains symbols.\n",
|
2020-05-14 20:50:56 +00:00
|
|
|
));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
WRAPPING_NEWLINE_CHARS,
|
|
|
|
false
|
|
|
|
));
|
2017-01-29 20:38:30 +00:00
|
|
|
}
|
|
|
|
|
2016-09-13 03:20:40 +00:00
|
|
|
#[test]
|
|
|
|
fn old_newline_chars() {
|
2018-01-25 04:05:05 +00:00
|
|
|
let app = App::new("ctest").version("0.1").arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("mode")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('m')
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Some help with some wrapping\n(Defaults to something)"),
|
2018-01-25 04:05:05 +00:00
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
OLD_NEWLINE_CHARS,
|
|
|
|
false
|
|
|
|
));
|
2016-09-13 03:20:40 +00:00
|
|
|
}
|
2016-10-20 23:37:39 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_688_hidden_pos_vals() {
|
2017-02-21 04:51:20 +00:00
|
|
|
let filter_values = ["Nearest", "Linear", "Cubic", "Gaussian", "Lanczos3"];
|
2016-10-20 23:37:39 +00:00
|
|
|
|
2017-02-21 04:51:20 +00:00
|
|
|
let app1 = App::new("ctest")
|
2016-10-20 23:37:39 +00:00
|
|
|
.version("0.1")
|
2020-05-18 07:51:36 +00:00
|
|
|
.term_width(120)
|
2016-10-20 23:37:39 +00:00
|
|
|
.setting(AppSettings::HidePossibleValuesInHelp)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("filter")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Sets the filter, or sampling method, to use for interpolation when resizing the particle \
|
2018-02-12 19:52:29 +00:00
|
|
|
images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]")
|
2016-10-20 23:37:39 +00:00
|
|
|
.long("filter")
|
|
|
|
.possible_values(&filter_values)
|
|
|
|
.takes_value(true));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app1,
|
|
|
|
"ctest --help",
|
|
|
|
ISSUE_688,
|
|
|
|
false
|
|
|
|
));
|
2016-10-20 23:37:39 +00:00
|
|
|
|
2017-02-21 04:51:20 +00:00
|
|
|
let app2 = App::new("ctest")
|
2016-10-20 23:37:39 +00:00
|
|
|
.version("0.1")
|
2020-05-18 07:51:36 +00:00
|
|
|
.term_width(120)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("filter")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Sets the filter, or sampling method, to use for interpolation when resizing the particle \
|
2016-10-20 23:37:39 +00:00
|
|
|
images. The default is Linear (Bilinear).")
|
|
|
|
.long("filter")
|
|
|
|
.possible_values(&filter_values)
|
|
|
|
.takes_value(true));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app2,
|
|
|
|
"ctest --help",
|
|
|
|
ISSUE_688,
|
|
|
|
false
|
|
|
|
));
|
2016-10-20 23:37:39 +00:00
|
|
|
|
2017-02-21 04:51:20 +00:00
|
|
|
let app3 = App::new("ctest")
|
2016-10-20 23:37:39 +00:00
|
|
|
.version("0.1")
|
2020-05-18 07:51:36 +00:00
|
|
|
.term_width(120)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("filter")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Sets the filter, or sampling method, to use for interpolation when resizing the particle \
|
2018-02-12 19:52:29 +00:00
|
|
|
images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]")
|
2016-10-20 23:37:39 +00:00
|
|
|
.long("filter")
|
|
|
|
.takes_value(true));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app3,
|
|
|
|
"ctest --help",
|
|
|
|
ISSUE_688,
|
|
|
|
false
|
|
|
|
));
|
2016-10-24 09:56:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_702_multiple_values() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version("1.0")
|
|
|
|
.author("foo")
|
|
|
|
.about("bar")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("arg1").about("some option"))
|
|
|
|
.arg(Arg::new("arg2").multiple(true).about("some option"))
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("some")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("some option")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('s')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("some")
|
|
|
|
.takes_value(true),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("other")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("some other option")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('o')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("other")
|
|
|
|
.takes_value(true),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("label")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("a label")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('l')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("label")
|
|
|
|
.multiple(true)
|
|
|
|
.takes_value(true),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(app, "myapp --help", ISSUE_702, false));
|
2016-12-01 23:47:20 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 18:41:49 +00:00
|
|
|
#[test]
|
|
|
|
fn long_about() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version("1.0")
|
|
|
|
.author("foo")
|
|
|
|
.about("bar")
|
2018-01-25 04:05:05 +00:00
|
|
|
.long_about(
|
|
|
|
"something really really long, with\nmultiple lines of text\nthat should be displayed",
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("arg1").about("some option"));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp --help",
|
|
|
|
LONG_ABOUT,
|
|
|
|
false
|
|
|
|
));
|
2017-09-13 18:41:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-01 23:47:20 +00:00
|
|
|
#[test]
|
|
|
|
fn issue_760() {
|
|
|
|
let app = App::new("ctest")
|
|
|
|
.version("0.1")
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("option")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("tests options")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('o')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("option")
|
|
|
|
.takes_value(true)
|
|
|
|
.multiple(true)
|
|
|
|
.number_of_values(1),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("opt")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("tests options")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('O')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("opt")
|
|
|
|
.takes_value(true),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(app, "ctest --help", ISSUE_760, false));
|
2017-01-02 21:44:40 +00:00
|
|
|
}
|
2017-03-09 13:52:37 +00:00
|
|
|
|
2017-03-24 03:51:43 +00:00
|
|
|
#[test]
|
|
|
|
fn ripgrep_usage() {
|
2018-10-19 20:42:13 +00:00
|
|
|
let app = App::new("ripgrep").version("0.5").override_usage(
|
2018-01-25 04:05:05 +00:00
|
|
|
"rg [OPTIONS] <pattern> [<path> ...]
|
2017-03-24 03:51:43 +00:00
|
|
|
rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
|
|
|
|
rg [OPTIONS] --files [<path> ...]
|
2018-01-25 04:05:05 +00:00
|
|
|
rg [OPTIONS] --type-list",
|
|
|
|
);
|
2017-03-24 03:51:43 +00:00
|
|
|
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"rg --help",
|
|
|
|
RIPGREP_USAGE,
|
|
|
|
false
|
|
|
|
));
|
2017-03-30 17:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn ripgrep_usage_using_templates() {
|
|
|
|
let app = App::new("ripgrep")
|
|
|
|
.version("0.5")
|
2018-10-19 20:42:13 +00:00
|
|
|
.override_usage(
|
2018-01-25 04:05:05 +00:00
|
|
|
"
|
2017-03-30 17:30:23 +00:00
|
|
|
rg [OPTIONS] <pattern> [<path> ...]
|
|
|
|
rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
|
|
|
|
rg [OPTIONS] --files [<path> ...]
|
2018-01-25 04:05:05 +00:00
|
|
|
rg [OPTIONS] --type-list",
|
|
|
|
)
|
2018-10-19 20:42:13 +00:00
|
|
|
.help_template(
|
2018-01-25 04:05:05 +00:00
|
|
|
"\
|
2017-03-30 17:30:23 +00:00
|
|
|
{bin} {version}
|
|
|
|
|
|
|
|
USAGE:{usage}
|
|
|
|
|
|
|
|
FLAGS:
|
2018-01-25 04:05:05 +00:00
|
|
|
{flags}",
|
|
|
|
);
|
2017-03-30 17:30:23 +00:00
|
|
|
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"rg --help",
|
|
|
|
RIPGREP_USAGE,
|
|
|
|
false
|
|
|
|
));
|
2017-03-24 03:51:43 +00:00
|
|
|
}
|
|
|
|
|
2017-03-09 13:52:37 +00:00
|
|
|
#[test]
|
|
|
|
fn sc_negates_reqs() {
|
|
|
|
let app = App::new("prog")
|
|
|
|
.version("1.0")
|
|
|
|
.setting(AppSettings::SubcommandsNegateReqs)
|
2018-10-19 20:42:13 +00:00
|
|
|
.arg("-o, --opt <FILE> 'tests options'")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("PATH").about("help"))
|
2018-10-19 20:42:13 +00:00
|
|
|
.subcommand(App::new("test"));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"prog --help",
|
|
|
|
SC_NEGATES_REQS,
|
|
|
|
false
|
|
|
|
));
|
2017-03-09 13:52:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-22 09:09:51 +00:00
|
|
|
#[test]
|
|
|
|
fn hidden_args() {
|
|
|
|
let app = App::new("prog")
|
|
|
|
.version("1.0")
|
2018-10-19 20:42:13 +00:00
|
|
|
.arg("-f, --flag 'testing flags'")
|
|
|
|
.arg("-o, --opt [FILE] 'tests options'")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("pos").hidden(true));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"prog --help",
|
|
|
|
HIDDEN_ARGS,
|
|
|
|
false
|
|
|
|
));
|
2017-11-22 09:09:51 +00:00
|
|
|
}
|
|
|
|
|
2017-03-09 13:52:37 +00:00
|
|
|
#[test]
|
|
|
|
fn args_negate_sc() {
|
|
|
|
let app = App::new("prog")
|
|
|
|
.version("1.0")
|
|
|
|
.setting(AppSettings::ArgsNegateSubcommands)
|
2018-10-19 20:42:13 +00:00
|
|
|
.arg("-f, --flag 'testing flags'")
|
|
|
|
.arg("-o, --opt [FILE] 'tests options'")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("PATH").about("help"))
|
2018-10-19 20:42:13 +00:00
|
|
|
.subcommand(App::new("test"));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"prog --help",
|
|
|
|
ARGS_NEGATE_SC,
|
|
|
|
false
|
|
|
|
));
|
2017-03-09 13:52:37 +00:00
|
|
|
}
|
|
|
|
|
2017-09-14 17:37:13 +00:00
|
|
|
#[test]
|
|
|
|
fn issue_1046_hidden_scs() {
|
|
|
|
let app = App::new("prog")
|
|
|
|
.version("1.0")
|
2018-10-19 20:42:13 +00:00
|
|
|
.arg("-f, --flag 'testing flags'")
|
|
|
|
.arg("-o, --opt [FILE] 'tests options'")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("PATH").about("some"))
|
2018-10-19 20:42:13 +00:00
|
|
|
.subcommand(App::new("test").setting(AppSettings::Hidden));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"prog --help",
|
|
|
|
ISSUE_1046_HIDDEN_SCS,
|
|
|
|
false
|
|
|
|
));
|
2017-09-14 17:37:13 +00:00
|
|
|
}
|
|
|
|
|
2017-01-02 21:44:40 +00:00
|
|
|
#[test]
|
|
|
|
fn issue_777_wrap_all_things() {
|
|
|
|
let app = App::new("A app with a crazy very long long long name hahaha")
|
|
|
|
.version("1.0")
|
|
|
|
.author("Some Very Long Name and crazy long email <email@server.com>")
|
|
|
|
.about("Show how the about text is not wrapped")
|
2020-05-18 07:51:36 +00:00
|
|
|
.term_width(35);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(app, "ctest --help", ISSUE_777, false));
|
2017-01-08 11:51:20 +00:00
|
|
|
}
|
2017-03-10 06:01:32 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn customize_version_and_help() {
|
|
|
|
let app = App::new("customize")
|
|
|
|
.version("0.1")
|
|
|
|
.author("Nobody <odysseus@example.com>")
|
|
|
|
.about("You can customize the version and help text")
|
2018-11-14 17:05:06 +00:00
|
|
|
.mut_arg("help", |h| {
|
2020-04-21 15:51:38 +00:00
|
|
|
h.short('H').long("help").about("Print help information")
|
2018-11-14 17:05:06 +00:00
|
|
|
})
|
|
|
|
.mut_arg("version", |v| {
|
|
|
|
v.short('v')
|
|
|
|
.long("version")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Print version information")
|
2018-11-14 17:05:06 +00:00
|
|
|
});
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"customize --help",
|
|
|
|
CUSTOM_VERSION_AND_HELP,
|
|
|
|
false
|
|
|
|
));
|
2017-03-10 06:01:32 +00:00
|
|
|
}
|
2017-03-11 05:17:57 +00:00
|
|
|
|
2020-04-08 20:26:05 +00:00
|
|
|
#[test]
|
|
|
|
fn arg_short_conflict_with_help() {
|
2020-05-14 20:50:56 +00:00
|
|
|
let app = App::new("conflict").arg(Arg::new("home").short('h'));
|
2020-04-08 20:26:05 +00:00
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"conflict --help",
|
|
|
|
HELP_CONFLICT,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2020-04-09 16:19:05 +00:00
|
|
|
#[cfg(debug_assertions)]
|
2020-04-08 20:26:05 +00:00
|
|
|
#[test]
|
2020-04-24 20:06:13 +00:00
|
|
|
#[should_panic = "Short option names must be unique for each argument, but '-h' is in use by both 'home' and 'help'"]
|
2020-04-08 20:26:05 +00:00
|
|
|
fn arg_short_conflict_with_help_mut_arg() {
|
|
|
|
let _ = App::new("conflict")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("home").short('h'))
|
2020-04-08 20:26:05 +00:00
|
|
|
.mut_arg("help", |h| h.short('h'))
|
|
|
|
.try_get_matches_from(vec![""]);
|
|
|
|
}
|
|
|
|
|
2017-03-11 05:17:57 +00:00
|
|
|
#[test]
|
|
|
|
fn last_arg_mult_usage() {
|
|
|
|
let app = App::new("last")
|
2018-01-25 04:05:05 +00:00
|
|
|
.version("0.1")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("TARGET").required(true).about("some"))
|
|
|
|
.arg(Arg::new("CORPUS").about("some"))
|
|
|
|
.arg(Arg::new("ARGS").multiple(true).last(true).about("some"));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(app, "last --help", LAST_ARG, false));
|
2017-03-11 05:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn last_arg_mult_usage_req() {
|
|
|
|
let app = App::new("last")
|
2018-01-25 04:05:05 +00:00
|
|
|
.version("0.1")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("TARGET").required(true).about("some"))
|
|
|
|
.arg(Arg::new("CORPUS").about("some"))
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("ARGS")
|
2018-01-25 04:05:05 +00:00
|
|
|
.multiple(true)
|
|
|
|
.last(true)
|
|
|
|
.required(true)
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("some"),
|
2018-01-25 04:05:05 +00:00
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"last --help",
|
|
|
|
LAST_ARG_REQ,
|
|
|
|
false
|
|
|
|
));
|
2017-03-11 05:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn last_arg_mult_usage_req_with_sc() {
|
|
|
|
let app = App::new("last")
|
2018-01-25 04:05:05 +00:00
|
|
|
.version("0.1")
|
|
|
|
.setting(AppSettings::SubcommandsNegateReqs)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("TARGET").required(true).about("some"))
|
|
|
|
.arg(Arg::new("CORPUS").about("some"))
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("ARGS")
|
2018-01-25 04:05:05 +00:00
|
|
|
.multiple(true)
|
|
|
|
.last(true)
|
|
|
|
.required(true)
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("some"),
|
2018-01-25 04:05:05 +00:00
|
|
|
)
|
2018-10-19 20:42:13 +00:00
|
|
|
.subcommand(App::new("test").about("some"));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"last --help",
|
|
|
|
LAST_ARG_REQ_SC,
|
|
|
|
false
|
|
|
|
));
|
2017-03-11 05:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn last_arg_mult_usage_with_sc() {
|
|
|
|
let app = App::new("last")
|
2018-01-25 04:05:05 +00:00
|
|
|
.version("0.1")
|
|
|
|
.setting(AppSettings::ArgsNegateSubcommands)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("TARGET").required(true).about("some"))
|
|
|
|
.arg(Arg::new("CORPUS").about("some"))
|
|
|
|
.arg(Arg::new("ARGS").multiple(true).last(true).about("some"))
|
2018-10-19 20:42:13 +00:00
|
|
|
.subcommand(App::new("test").about("some"));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"last --help",
|
|
|
|
LAST_ARG_SC,
|
|
|
|
false
|
|
|
|
));
|
2017-03-22 10:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hidden_default_val() {
|
2020-05-18 07:51:36 +00:00
|
|
|
let app1 = App::new("default").version("0.1").term_width(120).arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("argument")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Pass an argument to the program. [default: default-argument]")
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("arg")
|
|
|
|
.default_value("default-argument")
|
|
|
|
.hide_default_value(true),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app1,
|
|
|
|
"default --help",
|
|
|
|
HIDE_DEFAULT_VAL,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
|
2020-05-18 07:51:36 +00:00
|
|
|
let app2 = App::new("default").version("0.1").term_width(120).arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("argument")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Pass an argument to the program.")
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("arg")
|
|
|
|
.default_value("default-argument"),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app2,
|
|
|
|
"default --help",
|
|
|
|
HIDE_DEFAULT_VAL,
|
|
|
|
false
|
|
|
|
));
|
2017-03-22 10:14:02 +00:00
|
|
|
}
|
2017-04-04 23:54:20 +00:00
|
|
|
|
2020-09-23 08:45:14 +00:00
|
|
|
#[test]
|
|
|
|
fn escaped_whitespace_values() {
|
|
|
|
let app1 = App::new("default").version("0.1").term_width(120).arg(
|
|
|
|
Arg::new("argument")
|
|
|
|
.about("Pass an argument to the program.")
|
|
|
|
.long("arg")
|
|
|
|
.default_value("\n")
|
|
|
|
.possible_values(&["normal", " ", "\n", "\t", "other"]),
|
|
|
|
);
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app1,
|
|
|
|
"default --help",
|
|
|
|
ESCAPED_DEFAULT_VAL,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2019-04-05 02:06:23 +00:00
|
|
|
fn issue_1112_setup() -> App<'static> {
|
2017-11-22 09:09:51 +00:00
|
|
|
App::new("test")
|
2017-04-04 23:54:20 +00:00
|
|
|
.author("Kevin K.")
|
|
|
|
.about("tests stuff")
|
|
|
|
.version("1.3")
|
2018-10-21 02:27:31 +00:00
|
|
|
.global_setting(AppSettings::NoAutoHelp)
|
2018-04-21 18:59:19 +00:00
|
|
|
.arg(Arg::from("-h, --help 'some help'"))
|
2018-10-19 20:42:13 +00:00
|
|
|
.subcommand(App::new("foo").arg(Arg::from("-h, --help 'some help'")))
|
2017-11-22 09:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_1112_override_help_long() {
|
2018-10-19 20:42:13 +00:00
|
|
|
let m = issue_1112_setup().try_get_matches_from(vec!["test", "--help"]);
|
2017-04-04 23:54:20 +00:00
|
|
|
|
|
|
|
assert!(m.is_ok());
|
|
|
|
assert!(m.unwrap().is_present("help"));
|
2017-05-11 15:17:28 +00:00
|
|
|
}
|
2017-10-12 22:11:51 +00:00
|
|
|
|
2017-11-22 09:09:51 +00:00
|
|
|
#[test]
|
|
|
|
fn issue_1112_override_help_short() {
|
2018-10-19 20:42:13 +00:00
|
|
|
let m = issue_1112_setup().try_get_matches_from(vec!["test", "-h"]);
|
2017-11-22 09:09:51 +00:00
|
|
|
|
|
|
|
assert!(m.is_ok());
|
|
|
|
assert!(m.unwrap().is_present("help"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_1112_override_help_subcmd_long() {
|
2018-10-19 20:42:13 +00:00
|
|
|
let m = issue_1112_setup().try_get_matches_from(vec!["test", "foo", "--help"]);
|
2017-11-22 09:09:51 +00:00
|
|
|
|
|
|
|
assert!(m.is_ok());
|
2018-11-14 17:05:06 +00:00
|
|
|
assert!(m
|
|
|
|
.unwrap()
|
|
|
|
.subcommand_matches("foo")
|
|
|
|
.unwrap()
|
|
|
|
.is_present("help"));
|
2017-11-22 09:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_1112_override_help_subcmd_short() {
|
2018-10-19 20:42:13 +00:00
|
|
|
let m = issue_1112_setup().try_get_matches_from(vec!["test", "foo", "-h"]);
|
2017-11-22 09:09:51 +00:00
|
|
|
|
|
|
|
assert!(m.is_ok());
|
2018-11-14 17:05:06 +00:00
|
|
|
assert!(m
|
|
|
|
.unwrap()
|
|
|
|
.subcommand_matches("foo")
|
|
|
|
.unwrap()
|
|
|
|
.is_present("help"));
|
2017-11-22 09:09:51 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 22:11:51 +00:00
|
|
|
#[test]
|
|
|
|
fn issue_1052_require_delim_help() {
|
|
|
|
let app = App::new("test")
|
|
|
|
.author("Kevin K.")
|
|
|
|
.about("tests stuff")
|
|
|
|
.version("1.3")
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2018-04-21 18:59:19 +00:00
|
|
|
Arg::from("-f, --fake <some> <val> 'some help'")
|
2018-01-25 04:05:05 +00:00
|
|
|
.require_delimiter(true)
|
|
|
|
.value_delimiter(":"),
|
|
|
|
);
|
2017-10-12 22:11:51 +00:00
|
|
|
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"test --help",
|
|
|
|
REQUIRE_DELIM_HELP,
|
|
|
|
false
|
|
|
|
));
|
2017-10-12 22:11:51 +00:00
|
|
|
}
|
2017-12-02 19:21:30 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hide_env_vals() {
|
|
|
|
use std::env;
|
|
|
|
|
|
|
|
env::set_var("ENVVAR", "MYVAL");
|
|
|
|
let app = App::new("ctest")
|
|
|
|
.version("0.1")
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("pos")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('p')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("pos")
|
|
|
|
.value_name("VAL")
|
|
|
|
.possible_values(&["fast", "slow"])
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Some vals")
|
2018-01-25 04:05:05 +00:00
|
|
|
.takes_value(true),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("cafe")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('c')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("cafe")
|
|
|
|
.value_name("FILE")
|
|
|
|
.hide_env_values(true)
|
|
|
|
.env("ENVVAR")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("A coffeehouse, coffee shop, or café.")
|
2018-01-25 04:05:05 +00:00
|
|
|
.takes_value(true),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
HIDE_ENV_VALS,
|
|
|
|
false
|
|
|
|
));
|
2017-12-02 19:21:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn show_env_vals() {
|
|
|
|
use std::env;
|
|
|
|
|
|
|
|
env::set_var("ENVVAR", "MYVAL");
|
|
|
|
let app = App::new("ctest")
|
|
|
|
.version("0.1")
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("pos")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('p')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("pos")
|
|
|
|
.value_name("VAL")
|
|
|
|
.possible_values(&["fast", "slow"])
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Some vals")
|
2018-01-25 04:05:05 +00:00
|
|
|
.takes_value(true),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("cafe")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('c')
|
2018-01-25 04:05:05 +00:00
|
|
|
.long("cafe")
|
|
|
|
.value_name("FILE")
|
|
|
|
.hide_possible_values(true)
|
|
|
|
.env("ENVVAR")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("A coffeehouse, coffee shop, or café.")
|
2018-01-25 04:05:05 +00:00
|
|
|
.takes_value(true),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-01-25 04:05:05 +00:00
|
|
|
app,
|
|
|
|
"ctest --help",
|
|
|
|
SHOW_ENV_VALS,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
2018-04-04 03:27:57 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn custom_headers_headers() {
|
|
|
|
let app = App::new("blorp")
|
|
|
|
.author("Will M.")
|
|
|
|
.about("does stuff")
|
|
|
|
.version("1.4")
|
2018-07-23 19:09:42 +00:00
|
|
|
.arg(
|
|
|
|
Arg::from("-f, --fake <some> <val> 'some help'")
|
2018-04-04 03:27:57 +00:00
|
|
|
.require_delimiter(true)
|
|
|
|
.value_delimiter(":"),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.help_heading("NETWORKING")
|
2018-07-23 19:09:42 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("no-proxy")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('n')
|
2018-04-04 03:27:57 +00:00
|
|
|
.long("no-proxy")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Do not use system proxy settings"),
|
2018-04-04 03:27:57 +00:00
|
|
|
);
|
|
|
|
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-04-04 03:27:57 +00:00
|
|
|
app,
|
|
|
|
"test --help",
|
|
|
|
CUSTOM_HELP_SECTION,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static MULTIPLE_CUSTOM_HELP_SECTIONS: &str = "blorp 1.4
|
2018-04-04 03:27:57 +00:00
|
|
|
Will M.
|
|
|
|
does stuff
|
|
|
|
|
|
|
|
USAGE:
|
2020-06-01 06:04:41 +00:00
|
|
|
test [OPTIONS] --fake <some>:<val> --birthday-song <song> --birthday-song-volume <volume>
|
2018-04-04 03:27:57 +00:00
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-f, --fake <some>:<val> some help
|
|
|
|
-s, --speed <SPEED> How fast? [possible values: fast, slow]
|
|
|
|
|
|
|
|
NETWORKING:
|
2020-06-01 06:04:41 +00:00
|
|
|
-n, --no-proxy Do not use system proxy settings
|
|
|
|
-a, --server-addr Set server address
|
2018-04-04 03:27:57 +00:00
|
|
|
|
|
|
|
SPECIAL:
|
2020-06-01 06:04:41 +00:00
|
|
|
-b, --birthday-song <song> Change which song is played for birthdays
|
|
|
|
-v, --birthday-song-volume <volume> Change the volume of the birthday song";
|
2018-04-04 03:27:57 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn multiple_custom_help_headers() {
|
|
|
|
let app = App::new("blorp")
|
|
|
|
.author("Will M.")
|
|
|
|
.about("does stuff")
|
|
|
|
.version("1.4")
|
2018-07-23 19:09:42 +00:00
|
|
|
.arg(
|
|
|
|
Arg::from("-f, --fake <some> <val> 'some help'")
|
2018-04-04 03:27:57 +00:00
|
|
|
.require_delimiter(true)
|
|
|
|
.value_delimiter(":"),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.help_heading("NETWORKING")
|
2018-07-23 19:09:42 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("no-proxy")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('n')
|
2018-04-04 03:27:57 +00:00
|
|
|
.long("no-proxy")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Do not use system proxy settings"),
|
2018-11-14 17:05:06 +00:00
|
|
|
)
|
|
|
|
.help_heading("SPECIAL")
|
2020-06-01 06:04:41 +00:00
|
|
|
.arg(
|
|
|
|
Arg::from("-b, --birthday-song <song> 'Change which song is played for birthdays'")
|
|
|
|
.help_heading(Some("IGNORE THIS")),
|
|
|
|
)
|
2018-11-14 17:05:06 +00:00
|
|
|
.stop_custom_headings()
|
2020-06-01 06:04:41 +00:00
|
|
|
.arg(
|
|
|
|
Arg::from(
|
|
|
|
"-v --birthday-song-volume <volume> 'Change the volume of the birthday song'",
|
|
|
|
)
|
|
|
|
.help_heading(Some("SPECIAL")),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::new("server-addr")
|
|
|
|
.short('a')
|
|
|
|
.long("server-addr")
|
|
|
|
.about("Set server address")
|
|
|
|
.help_heading(Some("NETWORKING")),
|
|
|
|
)
|
2018-07-23 19:09:42 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("speed")
|
2018-04-04 03:27:57 +00:00
|
|
|
.long("speed")
|
2018-07-23 19:09:42 +00:00
|
|
|
.short('s')
|
2018-04-04 03:27:57 +00:00
|
|
|
.value_name("SPEED")
|
|
|
|
.possible_values(&["fast", "slow"])
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("How fast?")
|
2018-07-23 19:09:42 +00:00
|
|
|
.takes_value(true),
|
|
|
|
);
|
2018-04-04 03:27:57 +00:00
|
|
|
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-04-04 03:27:57 +00:00
|
|
|
app,
|
|
|
|
"test --help",
|
|
|
|
MULTIPLE_CUSTOM_HELP_SECTIONS,
|
|
|
|
false
|
|
|
|
));
|
2018-06-12 14:01:42 +00:00
|
|
|
}
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_897: &str = "ctest-foo 0.1
|
2018-06-12 14:01:42 +00:00
|
|
|
Long about foo
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest foo
|
|
|
|
|
|
|
|
FLAGS:
|
2020-08-20 12:45:38 +00:00
|
|
|
-h, --help
|
2018-06-12 14:01:42 +00:00
|
|
|
Prints help information
|
|
|
|
|
2020-08-20 12:45:38 +00:00
|
|
|
-V, --version
|
2018-06-12 14:01:42 +00:00
|
|
|
Prints version information";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn show_long_about_issue_897() {
|
2018-07-23 19:09:42 +00:00
|
|
|
let app = App::new("ctest").version("0.1").subcommand(
|
2018-10-19 20:42:13 +00:00
|
|
|
App::new("foo")
|
2018-06-12 14:01:42 +00:00
|
|
|
.version("0.1")
|
|
|
|
.about("About foo")
|
2018-07-23 19:09:42 +00:00
|
|
|
.long_about("Long about foo"),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-07-23 19:09:42 +00:00
|
|
|
app,
|
|
|
|
"ctest foo --help",
|
|
|
|
ISSUE_897,
|
|
|
|
false
|
|
|
|
));
|
2018-06-12 14:01:42 +00:00
|
|
|
}
|
|
|
|
|
2019-10-02 13:27:19 +00:00
|
|
|
static ISSUE_897_SHORT: &str = "ctest-foo 0.1
|
2020-02-13 00:31:45 +00:00
|
|
|
About foo
|
2018-06-12 14:01:42 +00:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
ctest foo
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn show_short_about_issue_897() {
|
2018-07-23 19:09:42 +00:00
|
|
|
let app = App::new("ctest").version("0.1").subcommand(
|
2018-10-19 20:42:13 +00:00
|
|
|
App::new("foo")
|
2018-06-12 14:01:42 +00:00
|
|
|
.version("0.1")
|
|
|
|
.about("About foo")
|
2018-07-23 19:09:42 +00:00
|
|
|
.long_about("Long about foo"),
|
|
|
|
);
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(
|
2018-07-23 19:09:42 +00:00
|
|
|
app,
|
|
|
|
"ctest foo -h",
|
|
|
|
ISSUE_897_SHORT,
|
|
|
|
false
|
|
|
|
));
|
2018-06-12 14:01:42 +00:00
|
|
|
}
|
2019-06-25 23:02:53 +00:00
|
|
|
|
2020-04-16 15:21:41 +00:00
|
|
|
#[test]
|
|
|
|
fn issue_1364_no_short_options() {
|
|
|
|
let app = App::new("demo")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("foo").short('f'))
|
2020-04-16 15:21:41 +00:00
|
|
|
.arg(
|
2020-05-14 20:50:56 +00:00
|
|
|
Arg::new("baz")
|
2020-04-16 15:21:41 +00:00
|
|
|
.short('z')
|
|
|
|
.value_name("BAZ")
|
|
|
|
.hidden_short_help(true),
|
|
|
|
)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("files").value_name("FILES").multiple(true));
|
2020-04-16 15:21:41 +00:00
|
|
|
|
|
|
|
assert!(utils::compare_output(app, "demo -h", ISSUE_1364, false));
|
|
|
|
}
|
|
|
|
|
2020-01-11 18:15:46 +00:00
|
|
|
#[rustfmt::skip]
|
2019-06-25 23:02:53 +00:00
|
|
|
#[test]
|
|
|
|
fn issue_1487() {
|
|
|
|
let app = App::new("test")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("arg1")
|
2019-06-25 23:02:53 +00:00
|
|
|
.group("group1"))
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("arg2")
|
2019-06-25 23:02:53 +00:00
|
|
|
.group("group1"))
|
2020-05-14 20:50:56 +00:00
|
|
|
.group(ArgGroup::new("group1")
|
2019-06-25 23:02:53 +00:00
|
|
|
.args(&["arg1", "arg2"])
|
|
|
|
.required(true));
|
2020-02-04 08:10:53 +00:00
|
|
|
assert!(utils::compare_output(app, "ctest -h", ISSUE_1487, false));
|
2020-01-11 18:15:46 +00:00
|
|
|
}
|
2020-02-10 10:04:18 +00:00
|
|
|
|
2020-04-09 16:19:05 +00:00
|
|
|
#[cfg(debug_assertions)]
|
2020-02-10 10:04:18 +00:00
|
|
|
#[test]
|
2020-04-09 22:33:16 +00:00
|
|
|
#[should_panic = "AppSettings::HelpRequired is enabled for the App"]
|
2020-02-10 10:04:18 +00:00
|
|
|
fn help_required_but_not_given() {
|
|
|
|
App::new("myapp")
|
|
|
|
.setting(AppSettings::HelpRequired)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("foo"))
|
2020-08-18 18:50:17 +00:00
|
|
|
.get_matches_from(empty_args());
|
2020-02-10 10:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 16:19:05 +00:00
|
|
|
#[cfg(debug_assertions)]
|
2020-02-10 10:04:18 +00:00
|
|
|
#[test]
|
2020-04-09 22:33:16 +00:00
|
|
|
#[should_panic = "AppSettings::HelpRequired is enabled for the App"]
|
2020-02-10 10:04:18 +00:00
|
|
|
fn help_required_but_not_given_settings_after_args() {
|
|
|
|
App::new("myapp")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("foo"))
|
2020-02-10 10:04:18 +00:00
|
|
|
.setting(AppSettings::HelpRequired)
|
2020-08-18 18:50:17 +00:00
|
|
|
.get_matches_from(empty_args());
|
2020-02-10 10:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 16:19:05 +00:00
|
|
|
#[cfg(debug_assertions)]
|
2020-02-10 10:04:18 +00:00
|
|
|
#[test]
|
2020-04-09 22:33:16 +00:00
|
|
|
#[should_panic = "AppSettings::HelpRequired is enabled for the App"]
|
2020-02-10 10:04:18 +00:00
|
|
|
fn help_required_but_not_given_for_one_of_two_arguments() {
|
|
|
|
App::new("myapp")
|
|
|
|
.setting(AppSettings::HelpRequired)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("foo"))
|
|
|
|
.arg(Arg::new("bar").about("It does bar stuff"))
|
2020-08-18 18:50:17 +00:00
|
|
|
.get_matches_from(empty_args());
|
2020-02-10 10:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-02-10 13:33:26 +00:00
|
|
|
fn help_required_locally_but_not_given_for_subcommand() {
|
2020-02-10 10:04:18 +00:00
|
|
|
App::new("myapp")
|
|
|
|
.setting(AppSettings::HelpRequired)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("foo").about("It does foo stuff"))
|
2020-02-10 13:33:26 +00:00
|
|
|
.subcommand(
|
|
|
|
App::new("bar")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("create").about("creates bar"))
|
|
|
|
.arg(Arg::new("delete")),
|
2020-02-10 13:33:26 +00:00
|
|
|
)
|
2020-08-18 18:50:17 +00:00
|
|
|
.get_matches_from(empty_args());
|
2020-02-10 13:33:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 16:19:05 +00:00
|
|
|
#[cfg(debug_assertions)]
|
2020-02-10 13:33:26 +00:00
|
|
|
#[test]
|
2020-04-09 22:33:16 +00:00
|
|
|
#[should_panic = "AppSettings::HelpRequired is enabled for the App"]
|
2020-02-10 13:33:26 +00:00
|
|
|
fn help_required_globally_but_not_given_for_subcommand() {
|
|
|
|
App::new("myapp")
|
|
|
|
.global_setting(AppSettings::HelpRequired)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("foo").about("It does foo stuff"))
|
2020-02-10 10:04:18 +00:00
|
|
|
.subcommand(
|
|
|
|
App::new("bar")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("create").about("creates bar"))
|
|
|
|
.arg(Arg::new("delete")),
|
2020-02-10 10:04:18 +00:00
|
|
|
)
|
2020-08-18 18:50:17 +00:00
|
|
|
.get_matches_from(empty_args());
|
2020-02-10 10:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_required_and_given_for_subcommand() {
|
|
|
|
App::new("myapp")
|
|
|
|
.setting(AppSettings::HelpRequired)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("foo").about("It does foo stuff"))
|
2020-02-10 10:04:18 +00:00
|
|
|
.subcommand(
|
|
|
|
App::new("bar")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("create").about("creates bar"))
|
|
|
|
.arg(Arg::new("delete").about("deletes bar")),
|
2020-02-10 10:04:18 +00:00
|
|
|
)
|
2020-08-18 18:50:17 +00:00
|
|
|
.get_matches_from(empty_args());
|
2020-02-10 10:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_required_and_given() {
|
|
|
|
App::new("myapp")
|
|
|
|
.setting(AppSettings::HelpRequired)
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("foo").about("It does foo stuff"))
|
2020-08-18 18:50:17 +00:00
|
|
|
.get_matches_from(empty_args());
|
2020-02-10 10:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_required_and_no_args() {
|
|
|
|
App::new("myapp")
|
|
|
|
.setting(AppSettings::HelpRequired)
|
2020-08-18 18:50:17 +00:00
|
|
|
.get_matches_from(empty_args());
|
2020-02-10 10:04:18 +00:00
|
|
|
}
|
2020-08-11 21:46:09 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_1642_long_help_spacing() {
|
|
|
|
let app = App::new("prog").arg(Arg::new("cfg").long("config").long_about(
|
|
|
|
"The config file used by the myprog must be in JSON format
|
|
|
|
with only valid keys and may not contain other nonsense
|
|
|
|
that cannot be read by this program. Obviously I'm going on
|
|
|
|
and on, so I'll stop now.",
|
|
|
|
));
|
|
|
|
assert!(utils::compare_output(app, "prog --help", ISSUE_1642, false));
|
|
|
|
}
|
2020-08-14 20:11:12 +00:00
|
|
|
|
|
|
|
const AFTER_HELP_NO_ARGS: &str = "myapp 1.0
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp
|
|
|
|
|
|
|
|
This is after help.
|
|
|
|
";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn after_help_no_args() {
|
|
|
|
let mut app = App::new("myapp")
|
|
|
|
.version("1.0")
|
|
|
|
.setting(AppSettings::DisableHelpFlags)
|
|
|
|
.setting(AppSettings::DisableVersion)
|
|
|
|
.after_help("This is after help.");
|
|
|
|
|
|
|
|
let help = {
|
|
|
|
let mut output = Vec::new();
|
|
|
|
app.write_help(&mut output).unwrap();
|
|
|
|
String::from_utf8(output).unwrap()
|
|
|
|
};
|
|
|
|
|
|
|
|
assert_eq!(help, AFTER_HELP_NO_ARGS);
|
|
|
|
}
|
2020-09-24 21:49:12 +00:00
|
|
|
|
|
|
|
static HELP_ABOUT: &str = "myapp 1.0
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Print custom help about text
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
|
|
|
static HELP_ABOUT_MULTI_SC: &str = "myapp-subcmd-multi 1.0
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp subcmd multi
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Print custom help about text
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
|
|
|
static HELP_ABOUT_MULTI_SC_OVERRIDE: &str = "myapp-subcmd-multi 1.0
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp subcmd multi
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Print custom help about text from multi
|
|
|
|
-V, --version Prints version information";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_about_short_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version("1.0")
|
|
|
|
.help_about("Print custom help about text");
|
|
|
|
|
|
|
|
assert!(utils::compare_output(app, "myapp -h", HELP_ABOUT, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_about_long_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version("1.0")
|
|
|
|
.help_about("Print custom help about text");
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp --help",
|
|
|
|
HELP_ABOUT,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_about_multi_subcmd() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.help_about("Print custom help about text")
|
|
|
|
.subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0")));
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp help subcmd multi",
|
|
|
|
HELP_ABOUT_MULTI_SC,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_about_multi_subcmd_short_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.help_about("Print custom help about text")
|
|
|
|
.subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0")));
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp subcmd multi -h",
|
|
|
|
HELP_ABOUT_MULTI_SC,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_about_multi_subcmd_long_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.help_about("Print custom help about text")
|
|
|
|
.subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0")));
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp subcmd multi --help",
|
|
|
|
HELP_ABOUT_MULTI_SC,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_about_multi_subcmd_override() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.help_about("Print custom help about text")
|
|
|
|
.subcommand(
|
|
|
|
App::new("subcmd").subcommand(
|
|
|
|
App::new("multi")
|
|
|
|
.version("1.0")
|
|
|
|
.help_about("Print custom help about text from multi"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp help subcmd multi",
|
|
|
|
HELP_ABOUT_MULTI_SC_OVERRIDE,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_about_multi_subcmd_override_short_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.help_about("Print custom help about text")
|
|
|
|
.subcommand(
|
|
|
|
App::new("subcmd").subcommand(
|
|
|
|
App::new("multi")
|
|
|
|
.version("1.0")
|
|
|
|
.help_about("Print custom help about text from multi"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp subcmd multi -h",
|
|
|
|
HELP_ABOUT_MULTI_SC_OVERRIDE,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_about_multi_subcmd_override_long_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.help_about("Print custom help about text")
|
|
|
|
.subcommand(
|
|
|
|
App::new("subcmd").subcommand(
|
|
|
|
App::new("multi")
|
|
|
|
.version("1.0")
|
|
|
|
.help_about("Print custom help about text from multi"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp subcmd multi --help",
|
|
|
|
HELP_ABOUT_MULTI_SC_OVERRIDE,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
2020-09-25 13:06:10 +00:00
|
|
|
|
|
|
|
static VERSION_ABOUT: &str = "myapp 1.0
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Print custom version about text";
|
|
|
|
|
|
|
|
static VERSION_ABOUT_MULTI_SC: &str = "myapp-subcmd-multi 1.0
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp subcmd multi
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Print custom version about text";
|
|
|
|
|
|
|
|
static VERSION_ABOUT_MULTI_SC_OVERRIDE: &str = "myapp-subcmd-multi 1.0
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
myapp subcmd multi
|
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Print custom version about text from multi";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_about_short_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version("1.0")
|
|
|
|
.version_about("Print custom version about text");
|
|
|
|
|
|
|
|
assert!(utils::compare_output(app, "myapp -h", VERSION_ABOUT, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_about_long_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version("1.0")
|
|
|
|
.version_about("Print custom version about text");
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp --help",
|
|
|
|
VERSION_ABOUT,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_about_multi_subcmd() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version_about("Print custom version about text")
|
|
|
|
.subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0")));
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp help subcmd multi",
|
|
|
|
VERSION_ABOUT_MULTI_SC,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_about_multi_subcmd_short_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version_about("Print custom version about text")
|
|
|
|
.subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0")));
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp subcmd multi -h",
|
|
|
|
VERSION_ABOUT_MULTI_SC,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_about_multi_subcmd_long_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version_about("Print custom version about text")
|
|
|
|
.subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0")));
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp subcmd multi --help",
|
|
|
|
VERSION_ABOUT_MULTI_SC,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_about_multi_subcmd_override() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version_about("Print custom version about text")
|
|
|
|
.subcommand(
|
|
|
|
App::new("subcmd").subcommand(
|
|
|
|
App::new("multi")
|
|
|
|
.version("1.0")
|
|
|
|
.version_about("Print custom version about text from multi"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp help subcmd multi",
|
|
|
|
VERSION_ABOUT_MULTI_SC_OVERRIDE,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_about_multi_subcmd_override_short_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version_about("Print custom version about text")
|
|
|
|
.subcommand(
|
|
|
|
App::new("subcmd").subcommand(
|
|
|
|
App::new("multi")
|
|
|
|
.version("1.0")
|
|
|
|
.version_about("Print custom version about text from multi"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp subcmd multi -h",
|
|
|
|
VERSION_ABOUT_MULTI_SC_OVERRIDE,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_about_multi_subcmd_override_long_flag() {
|
|
|
|
let app = App::new("myapp")
|
|
|
|
.version_about("Print custom version about text")
|
|
|
|
.subcommand(
|
|
|
|
App::new("subcmd").subcommand(
|
|
|
|
App::new("multi")
|
|
|
|
.version("1.0")
|
|
|
|
.version_about("Print custom version about text from multi"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(utils::compare_output(
|
|
|
|
app,
|
|
|
|
"myapp subcmd multi --help",
|
|
|
|
VERSION_ABOUT_MULTI_SC_OVERRIDE,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
}
|