mirror of
https://github.com/clap-rs/clap
synced 2024-12-05 02:29:12 +00:00
chore: Update snapbox/trycmd
This commit is contained in:
parent
f45a32ec2c
commit
5f9cecb6bd
35 changed files with 417 additions and 376 deletions
31
Cargo.lock
generated
31
Cargo.lock
generated
|
@ -3022,9 +3022,9 @@ checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043"
|
|||
|
||||
[[package]]
|
||||
name = "snapbox"
|
||||
version = "0.4.16"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73145a30df4935f50a7b13c1882bce7d194d7071ad0bcc36e7cacbf9ef16e3ec"
|
||||
checksum = "8269b717f21b142c0377f1e617e80999e3ef6b1c010959b44fd93320722d2cba"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
|
@ -3045,9 +3045,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "snapbox-macros"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ccde059aad940984ff696fe8c280900f7ea71a6fb45fce65071a3f2c40b667"
|
||||
checksum = "e1c4b838b05d15ab22754068cb73500b2f3b07bf09d310e15b27f88160f1de40"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
]
|
||||
|
@ -3354,20 +3354,20 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
"winnow 0.5.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.21.1"
|
||||
version = "0.22.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
|
||||
checksum = "99e68c159e8f5ba8a28c4eb7b0c0c190d77bb479047ca713270048145a9ad28a"
|
||||
dependencies = [
|
||||
"indexmap 2.1.0",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
"winnow 0.6.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3387,9 +3387,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "trycmd"
|
||||
version = "0.14.20"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7ad3a033f38ca4d9eedf36ba792622027119c61b62b57970c5bed42cfd0c40d"
|
||||
checksum = "464edb3603a81a50b4c8f47b11dfade69ef48ffdc0af2f8b194ad87cbda75317"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"humantime",
|
||||
|
@ -3398,7 +3398,7 @@ dependencies = [
|
|||
"serde",
|
||||
"shlex",
|
||||
"snapbox",
|
||||
"toml_edit 0.21.1",
|
||||
"toml_edit 0.22.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4132,6 +4132,15 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.52.0"
|
||||
|
|
|
@ -109,9 +109,9 @@ clap_derive = { path = "./clap_derive", version = "=4.5.0", optional = true }
|
|||
trybuild = "1.0.89"
|
||||
rustversion = "1.0.14"
|
||||
# Cutting out `filesystem` feature
|
||||
trycmd = { version = "0.14.20", default-features = false, features = ["color-auto", "diff", "examples"] }
|
||||
trycmd = { version = "0.15.0", default-features = false, features = ["color-auto", "diff", "examples"] }
|
||||
humantime = "2.1.0"
|
||||
snapbox = "0.4.16"
|
||||
snapbox = "0.5.0"
|
||||
shlex = "1.3.0"
|
||||
|
||||
[[example]]
|
||||
|
|
|
@ -42,9 +42,9 @@ shlex = { version = "1.1.0", optional = true }
|
|||
unicode-xid = { version = "0.2.2", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
snapbox = { version = "0.4.16", features = ["diff", "path", "examples"] }
|
||||
snapbox = { version = "0.5.0", features = ["diff", "path", "examples"] }
|
||||
# Cutting out `filesystem` feature
|
||||
trycmd = { version = "0.14.20", default-features = false, features = ["color-auto", "diff", "examples"] }
|
||||
trycmd = { version = "0.15.0", default-features = false, features = ["color-auto", "diff", "examples"] }
|
||||
completest = "0.4.0"
|
||||
completest-pty = "0.5.0"
|
||||
clap = { path = "../", version = "4.0.0", default-features = false, features = ["std", "derive", "help"] }
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::common;
|
|||
fn basic() {
|
||||
let name = "my-app";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/basic.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/basic.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -16,8 +16,8 @@ fn basic() {
|
|||
fn feature_sample() {
|
||||
let name = "my-app";
|
||||
let cmd = common::feature_sample_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/feature_sample.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/feature_sample.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -28,8 +28,8 @@ fn feature_sample() {
|
|||
fn special_commands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::special_commands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/special_commands.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/special_commands.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -40,8 +40,8 @@ fn special_commands() {
|
|||
fn quoting() {
|
||||
let name = "my-app";
|
||||
let cmd = common::quoting_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/quoting.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/quoting.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -52,8 +52,8 @@ fn quoting() {
|
|||
fn aliases() {
|
||||
let name = "my-app";
|
||||
let cmd = common::aliases_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/aliases.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/aliases.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -64,8 +64,8 @@ fn aliases() {
|
|||
fn sub_subcommands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::sub_subcommands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/sub_subcommands.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/sub_subcommands.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -77,8 +77,8 @@ fn custom_bin_name() {
|
|||
let name = "my-app";
|
||||
let bin_name = "bin-name";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/custom_bin_name.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/custom_bin_name.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
bin_name,
|
||||
|
@ -89,8 +89,8 @@ fn custom_bin_name() {
|
|||
fn value_hint() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_hint_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_hint.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_hint.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -101,8 +101,8 @@ fn value_hint() {
|
|||
fn value_terminator() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_terminator_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_terminator.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_terminator.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -124,15 +124,15 @@ fn register_minimal() {
|
|||
.unwrap();
|
||||
snapbox::Assert::new()
|
||||
.action_env("SNAPSHOTS")
|
||||
.matches_path("tests/snapshots/register_minimal.bash", buf);
|
||||
.matches(snapbox::file!["../snapshots/register_minimal.bash"], buf);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_multi_valued_arguments() {
|
||||
let name = "my-app";
|
||||
let cmd = common::two_multi_valued_arguments_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/two_multi_valued_arguments.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/two_multi_valued_arguments.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -143,8 +143,8 @@ fn two_multi_valued_arguments() {
|
|||
fn subcommand_last() {
|
||||
let name = "my-app";
|
||||
let cmd = common::subcommand_last(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/subcommand_last.bash",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/subcommand_last.bash"],
|
||||
clap_complete::shells::Bash,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -241,7 +241,7 @@ fn complete() {
|
|||
}
|
||||
|
||||
let input = "exhaustive hint --other \t";
|
||||
let expected = "exhaustive hint --other % exhaustive hint --other ";
|
||||
let expected = snapbox::str!["exhaustive hint --other % exhaustive hint --other "];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
snapbox::assert_eq(expected, actual);
|
||||
}
|
||||
|
|
|
@ -281,8 +281,8 @@ pub fn subcommand_last(name: &'static str) -> clap::Command {
|
|||
.subcommands([clap::Command::new("foo"), clap::Command::new("bar")])
|
||||
}
|
||||
|
||||
pub fn assert_matches_path(
|
||||
expected_path: impl AsRef<std::path::Path>,
|
||||
pub fn assert_matches(
|
||||
expected: impl Into<snapbox::Data>,
|
||||
gen: impl clap_complete::Generator,
|
||||
mut cmd: clap::Command,
|
||||
name: &'static str,
|
||||
|
@ -291,9 +291,9 @@ pub fn assert_matches_path(
|
|||
clap_complete::generate(gen, &mut cmd, name, &mut buf);
|
||||
|
||||
snapbox::Assert::new()
|
||||
.action_env("SNAPSHOTS")
|
||||
.action_env(snapbox::DEFAULT_ACTION_ENV)
|
||||
.normalize_paths(false)
|
||||
.matches_path(expected_path, buf);
|
||||
.matches(expected, buf);
|
||||
}
|
||||
|
||||
pub fn register_example<R: completest::RuntimeBuilder>(context: &str, name: &str) {
|
||||
|
|
|
@ -23,9 +23,11 @@ fn suggest_subcommand_subset() {
|
|||
.subcommand(Command::new("goodbye-world"));
|
||||
|
||||
snapbox::assert_eq(
|
||||
"hello-moon
|
||||
snapbox::str![
|
||||
"hello-moon
|
||||
hello-world
|
||||
help\tPrint this message or the help of the given subcommand(s)",
|
||||
help\tPrint this message or the help of the given subcommand(s)"
|
||||
],
|
||||
complete!(cmd, "he"),
|
||||
);
|
||||
}
|
||||
|
@ -50,9 +52,11 @@ fn suggest_long_flag_subset() {
|
|||
);
|
||||
|
||||
snapbox::assert_eq(
|
||||
"--hello-world
|
||||
snapbox::str![
|
||||
"--hello-world
|
||||
--hello-moon
|
||||
--help\tPrint help",
|
||||
--help\tPrint help"
|
||||
],
|
||||
complete!(cmd, "--he"),
|
||||
);
|
||||
}
|
||||
|
@ -67,8 +71,10 @@ fn suggest_possible_value_subset() {
|
|||
]));
|
||||
|
||||
snapbox::assert_eq(
|
||||
"hello-world\tSay hello to the world
|
||||
hello-moon",
|
||||
snapbox::str![
|
||||
"hello-world\tSay hello to the world
|
||||
hello-moon"
|
||||
],
|
||||
complete!(cmd, "hello"),
|
||||
);
|
||||
}
|
||||
|
@ -93,10 +99,12 @@ fn suggest_additional_short_flags() {
|
|||
);
|
||||
|
||||
snapbox::assert_eq(
|
||||
"-aa
|
||||
snapbox::str![
|
||||
"-aa
|
||||
-ab
|
||||
-ac
|
||||
-ah\tPrint help",
|
||||
-ah\tPrint help"
|
||||
],
|
||||
complete!(cmd, "-a"),
|
||||
);
|
||||
}
|
||||
|
@ -112,11 +120,13 @@ fn suggest_subcommand_positional() {
|
|||
));
|
||||
|
||||
snapbox::assert_eq(
|
||||
"--help\tPrint help (see more with '--help')
|
||||
snapbox::str![
|
||||
"--help\tPrint help (see more with '--help')
|
||||
-h\tPrint help (see more with '--help')
|
||||
hello-world\tSay hello to the world
|
||||
hello-moon
|
||||
goodbye-world",
|
||||
goodbye-world"
|
||||
],
|
||||
complete!(cmd, "hello-world [TAB]"),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::common;
|
|||
fn basic() {
|
||||
let name = "my-app";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/basic.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/basic.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -16,8 +16,8 @@ fn basic() {
|
|||
fn feature_sample() {
|
||||
let name = "my-app";
|
||||
let cmd = common::feature_sample_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/feature_sample.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/feature_sample.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -28,8 +28,8 @@ fn feature_sample() {
|
|||
fn special_commands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::special_commands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/special_commands.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/special_commands.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -40,8 +40,8 @@ fn special_commands() {
|
|||
fn quoting() {
|
||||
let name = "my-app";
|
||||
let cmd = common::quoting_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/quoting.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/quoting.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -52,8 +52,8 @@ fn quoting() {
|
|||
fn aliases() {
|
||||
let name = "my-app";
|
||||
let cmd = common::aliases_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/aliases.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/aliases.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -64,8 +64,8 @@ fn aliases() {
|
|||
fn sub_subcommands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::sub_subcommands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/sub_subcommands.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/sub_subcommands.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -77,8 +77,8 @@ fn custom_bin_name() {
|
|||
let name = "my-app";
|
||||
let bin_name = "bin-name";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/custom_bin_name.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/custom_bin_name.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
bin_name,
|
||||
|
@ -89,8 +89,8 @@ fn custom_bin_name() {
|
|||
fn value_hint() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_hint_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_hint.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_hint.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -101,8 +101,8 @@ fn value_hint() {
|
|||
fn value_terminator() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_terminator_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_terminator.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_terminator.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -113,8 +113,8 @@ fn value_terminator() {
|
|||
fn two_multi_valued_arguments() {
|
||||
let name = "my-app";
|
||||
let cmd = common::two_multi_valued_arguments_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/two_multi_valued_arguments.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/two_multi_valued_arguments.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -125,8 +125,8 @@ fn two_multi_valued_arguments() {
|
|||
fn subcommand_last() {
|
||||
let name = "my-app";
|
||||
let cmd = common::subcommand_last(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/subcommand_last.elvish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/subcommand_last.elvish"],
|
||||
clap_complete::shells::Elvish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -151,7 +151,8 @@ fn complete() {
|
|||
common::load_runtime::<completest_pty::ElvishRuntimeBuilder>("static", "exhaustive");
|
||||
|
||||
let input = "exhaustive \t";
|
||||
let expected = r#"% exhaustive --generate
|
||||
let expected = snapbox::str![
|
||||
r#"% exhaustive --generate
|
||||
COMPLETING argument
|
||||
--generate generate
|
||||
--global everywhere
|
||||
|
@ -167,7 +168,8 @@ hint hint
|
|||
last last
|
||||
pacman pacman
|
||||
quote quote
|
||||
value value "#;
|
||||
value value "#
|
||||
];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
snapbox::assert_eq(expected, actual);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::common;
|
|||
fn basic() {
|
||||
let name = "my-app";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/basic.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/basic.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -16,8 +16,8 @@ fn basic() {
|
|||
fn feature_sample() {
|
||||
let name = "my-app";
|
||||
let cmd = common::feature_sample_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/feature_sample.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/feature_sample.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -28,8 +28,8 @@ fn feature_sample() {
|
|||
fn special_commands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::special_commands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/special_commands.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/special_commands.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -40,8 +40,8 @@ fn special_commands() {
|
|||
fn quoting() {
|
||||
let name = "my-app";
|
||||
let cmd = common::quoting_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/quoting.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/quoting.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -52,8 +52,8 @@ fn quoting() {
|
|||
fn aliases() {
|
||||
let name = "my-app";
|
||||
let cmd = common::aliases_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/aliases.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/aliases.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -64,8 +64,8 @@ fn aliases() {
|
|||
fn sub_subcommands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::sub_subcommands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/sub_subcommands.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/sub_subcommands.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -77,8 +77,8 @@ fn custom_bin_name() {
|
|||
let name = "my-app";
|
||||
let bin_name = "bin-name";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/custom_bin_name.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/custom_bin_name.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
bin_name,
|
||||
|
@ -89,8 +89,8 @@ fn custom_bin_name() {
|
|||
fn value_hint() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_hint_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_hint.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_hint.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -101,8 +101,8 @@ fn value_hint() {
|
|||
fn value_terminator() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_terminator_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_terminator.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_terminator.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -113,8 +113,8 @@ fn value_terminator() {
|
|||
fn two_multi_valued_arguments() {
|
||||
let name = "my-app";
|
||||
let cmd = common::two_multi_valued_arguments_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/two_multi_valued_arguments.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/two_multi_valued_arguments.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -125,8 +125,8 @@ fn two_multi_valued_arguments() {
|
|||
fn subcommand_last() {
|
||||
let name = "my-app";
|
||||
let cmd = common::subcommand_last(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/subcommand_last.fish",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/subcommand_last.fish"],
|
||||
clap_complete::shells::Fish,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -182,17 +182,20 @@ fn complete_dynamic() {
|
|||
common::load_runtime::<completest_pty::FishRuntimeBuilder>("dynamic", "exhaustive");
|
||||
|
||||
let input = "exhaustive \t";
|
||||
let expected = r#"% exhaustive
|
||||
let expected = snapbox::str![
|
||||
r#"% exhaustive
|
||||
action last -V (Print version)
|
||||
alias pacman --generate (generate)
|
||||
complete (Register shell completions for this program) quote --global (everywhere)
|
||||
help (Print this message or the help of the given subcommand(s)) value --help (Print help)
|
||||
hint -h (Print help) --version (Print version)"#;
|
||||
hint -h (Print help) --version (Print version)"#
|
||||
];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
snapbox::assert_eq(expected, actual);
|
||||
|
||||
let input = "exhaustive quote \t";
|
||||
let expected = r#"% exhaustive quote
|
||||
let expected = snapbox::str![
|
||||
r#"% exhaustive quote
|
||||
cmd-backslash (Avoid '\n')
|
||||
cmd-backticks (For more information see `echo test`)
|
||||
cmd-brackets (List packages [filter])
|
||||
|
@ -211,7 +214,8 @@ help (Print this message or the help of the given subcommand(s))
|
|||
--global (everywhere)
|
||||
--help (Print help)
|
||||
--single-quotes (Can be 'always', 'auto', or 'never')
|
||||
--version (Print version)"#;
|
||||
--version (Print version)"#
|
||||
];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
snapbox::assert_eq(expected, actual);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::common;
|
|||
fn basic() {
|
||||
let name = "my-app";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/basic.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/basic.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -16,8 +16,8 @@ fn basic() {
|
|||
fn feature_sample() {
|
||||
let name = "my-app";
|
||||
let cmd = common::feature_sample_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/feature_sample.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/feature_sample.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -28,8 +28,8 @@ fn feature_sample() {
|
|||
fn special_commands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::special_commands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/special_commands.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/special_commands.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -40,8 +40,8 @@ fn special_commands() {
|
|||
fn quoting() {
|
||||
let name = "my-app";
|
||||
let cmd = common::quoting_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/quoting.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/quoting.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -52,8 +52,8 @@ fn quoting() {
|
|||
fn aliases() {
|
||||
let name = "my-app";
|
||||
let cmd = common::aliases_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/aliases.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/aliases.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -64,8 +64,8 @@ fn aliases() {
|
|||
fn sub_subcommands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::sub_subcommands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/sub_subcommands.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/sub_subcommands.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -77,8 +77,8 @@ fn custom_bin_name() {
|
|||
let name = "my-app";
|
||||
let bin_name = "bin-name";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/custom_bin_name.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/custom_bin_name.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
bin_name,
|
||||
|
@ -89,8 +89,8 @@ fn custom_bin_name() {
|
|||
fn value_hint() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_hint_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_hint.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_hint.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -101,8 +101,8 @@ fn value_hint() {
|
|||
fn value_terminator() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_terminator_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_terminator.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_terminator.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -113,8 +113,8 @@ fn value_terminator() {
|
|||
fn two_multi_valued_arguments() {
|
||||
let name = "my-app";
|
||||
let cmd = common::two_multi_valued_arguments_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/two_multi_valued_arguments.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/two_multi_valued_arguments.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -125,8 +125,8 @@ fn two_multi_valued_arguments() {
|
|||
fn subcommand_last() {
|
||||
let name = "my-app";
|
||||
let cmd = common::subcommand_last(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/subcommand_last.ps1",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/subcommand_last.ps1"],
|
||||
clap_complete::shells::PowerShell,
|
||||
cmd,
|
||||
name,
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::common;
|
|||
fn basic() {
|
||||
let name = "my-app";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/basic.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/basic.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -16,8 +16,8 @@ fn basic() {
|
|||
fn feature_sample() {
|
||||
let name = "my-app";
|
||||
let cmd = common::feature_sample_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/feature_sample.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/feature_sample.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -28,8 +28,8 @@ fn feature_sample() {
|
|||
fn special_commands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::special_commands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/special_commands.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/special_commands.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -40,8 +40,8 @@ fn special_commands() {
|
|||
fn quoting() {
|
||||
let name = "my-app";
|
||||
let cmd = common::quoting_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/quoting.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/quoting.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -52,8 +52,8 @@ fn quoting() {
|
|||
fn aliases() {
|
||||
let name = "my-app";
|
||||
let cmd = common::aliases_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/aliases.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/aliases.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -64,8 +64,8 @@ fn aliases() {
|
|||
fn sub_subcommands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::sub_subcommands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/sub_subcommands.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/sub_subcommands.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -77,8 +77,8 @@ fn custom_bin_name() {
|
|||
let name = "my-app";
|
||||
let bin_name = "bin-name";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/custom_bin_name.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/custom_bin_name.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
bin_name,
|
||||
|
@ -89,8 +89,8 @@ fn custom_bin_name() {
|
|||
fn value_hint() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_hint_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_hint.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_hint.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -101,8 +101,8 @@ fn value_hint() {
|
|||
fn value_terminator() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_terminator_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_terminator.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/value_terminator.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -113,8 +113,8 @@ fn value_terminator() {
|
|||
fn two_multi_valued_arguments() {
|
||||
let name = "my-app";
|
||||
let cmd = common::two_multi_valued_arguments_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/two_multi_valued_arguments.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/two_multi_valued_arguments.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -125,8 +125,8 @@ fn two_multi_valued_arguments() {
|
|||
fn subcommand_last() {
|
||||
let name = "my-app";
|
||||
let cmd = common::subcommand_last(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/subcommand_last.zsh",
|
||||
common::assert_matches(
|
||||
snapbox::file!["../snapshots/subcommand_last.zsh"],
|
||||
clap_complete::shells::Zsh,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -151,10 +151,12 @@ fn complete() {
|
|||
common::load_runtime::<completest_pty::ZshRuntimeBuilder>("static", "exhaustive");
|
||||
|
||||
let input = "exhaustive \t";
|
||||
let expected = r#"% exhaustive
|
||||
let expected = snapbox::str![
|
||||
r#"% exhaustive
|
||||
complete -- Register shell completions for this program
|
||||
help -- Print this message or the help of the given subcommand(s)
|
||||
pacman action alias value quote hint last -- "#;
|
||||
pacman action alias value quote hint last -- "#
|
||||
];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
snapbox::assert_eq(expected, actual);
|
||||
}
|
||||
|
|
|
@ -35,5 +35,5 @@ clap = { path = "../", version = "4.0.0", default-features = false, features = [
|
|||
clap_complete = { path = "../clap_complete", version = "4.0.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
snapbox = { version = "0.4.16", features = ["diff"] }
|
||||
snapbox = { version = "0.5.0", features = ["diff"] }
|
||||
clap = { path = "../", version = "4.0.0", default-features = false, features = ["std", "help"] }
|
||||
|
|
|
@ -247,8 +247,8 @@ pub fn value_hint_command(name: &'static str) -> clap::Command {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn assert_matches_path(
|
||||
expected_path: impl AsRef<std::path::Path>,
|
||||
pub fn assert_matches(
|
||||
expected: impl Into<snapbox::Data>,
|
||||
gen: impl clap_complete::Generator,
|
||||
mut cmd: clap::Command,
|
||||
name: &'static str,
|
||||
|
@ -257,6 +257,7 @@ pub fn assert_matches_path(
|
|||
clap_complete::generate(gen, &mut cmd, name, &mut buf);
|
||||
|
||||
snapbox::Assert::new()
|
||||
.action_env("SNAPSHOTS")
|
||||
.matches_path(expected_path, buf);
|
||||
.action_env(snapbox::DEFAULT_ACTION_ENV)
|
||||
.normalize_paths(false)
|
||||
.matches(expected, buf);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ mod common;
|
|||
fn basic() {
|
||||
let name = "my-app";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/basic.fig.js",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/basic.fig.js"],
|
||||
clap_complete_fig::Fig,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -16,8 +16,8 @@ fn basic() {
|
|||
fn feature_sample() {
|
||||
let name = "my-app";
|
||||
let cmd = common::feature_sample_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/feature_sample.fig.js",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/feature_sample.fig.js"],
|
||||
clap_complete_fig::Fig,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -28,8 +28,8 @@ fn feature_sample() {
|
|||
fn special_commands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::special_commands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/special_commands.fig.js",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/special_commands.fig.js"],
|
||||
clap_complete_fig::Fig,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -40,8 +40,8 @@ fn special_commands() {
|
|||
fn quoting() {
|
||||
let name = "my-app";
|
||||
let cmd = common::quoting_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/quoting.fig.js",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/quoting.fig.js"],
|
||||
clap_complete_fig::Fig,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -52,8 +52,8 @@ fn quoting() {
|
|||
fn aliases() {
|
||||
let name = "my-app";
|
||||
let cmd = common::aliases_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/aliases.fig.js",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/aliases.fig.js"],
|
||||
clap_complete_fig::Fig,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -64,8 +64,8 @@ fn aliases() {
|
|||
fn sub_subcommands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::sub_subcommands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/sub_subcommands.fig.js",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/sub_subcommands.fig.js"],
|
||||
clap_complete_fig::Fig,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -76,8 +76,8 @@ fn sub_subcommands() {
|
|||
fn value_hint() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_hint_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_hint.fig.js",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/value_hint.fig.js"],
|
||||
clap_complete_fig::Fig,
|
||||
cmd,
|
||||
name,
|
||||
|
|
|
@ -14,7 +14,7 @@ const completion: Fig.Spec = {
|
|||
},
|
||||
{
|
||||
name: "cmd-double-quotes",
|
||||
description: "Can be /"always/", /"auto/", or /"never/"",
|
||||
description: "Can be \"always\", \"auto\", or \"never\"",
|
||||
options: [
|
||||
{
|
||||
name: ["-h", "--help"],
|
||||
|
@ -34,7 +34,7 @@ const completion: Fig.Spec = {
|
|||
},
|
||||
{
|
||||
name: "cmd-backslash",
|
||||
description: "Avoid '//n'",
|
||||
description: "Avoid '\\n'",
|
||||
options: [
|
||||
{
|
||||
name: ["-h", "--help"],
|
||||
|
@ -72,7 +72,7 @@ const completion: Fig.Spec = {
|
|||
},
|
||||
{
|
||||
name: "cmd-double-quotes",
|
||||
description: "Can be /"always/", /"auto/", or /"never/"",
|
||||
description: "Can be \"always\", \"auto\", or \"never\"",
|
||||
},
|
||||
{
|
||||
name: "cmd-backticks",
|
||||
|
@ -80,7 +80,7 @@ const completion: Fig.Spec = {
|
|||
},
|
||||
{
|
||||
name: "cmd-backslash",
|
||||
description: "Avoid '//n'",
|
||||
description: "Avoid '\\n'",
|
||||
},
|
||||
{
|
||||
name: "cmd-brackets",
|
||||
|
@ -104,7 +104,7 @@ const completion: Fig.Spec = {
|
|||
},
|
||||
{
|
||||
name: "--double-quotes",
|
||||
description: "Can be /"always/", /"auto/", or /"never/"",
|
||||
description: "Can be \"always\", \"auto\", or \"never\"",
|
||||
},
|
||||
{
|
||||
name: "--backticks",
|
||||
|
@ -112,7 +112,7 @@ const completion: Fig.Spec = {
|
|||
},
|
||||
{
|
||||
name: "--backslash",
|
||||
description: "Avoid '//n'",
|
||||
description: "Avoid '\\n'",
|
||||
},
|
||||
{
|
||||
name: "--brackets",
|
||||
|
|
|
@ -35,7 +35,7 @@ clap = { path = "../", version = "4.0.0", default-features = false, features = [
|
|||
clap_complete = { path = "../clap_complete", version = "4.0.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
snapbox = { version = "0.4.16", features = ["diff", "examples", "path"] }
|
||||
snapbox = { version = "0.5.0", features = ["diff", "examples", "path"] }
|
||||
clap = { path = "../", version = "4.0.0", default-features = false, features = ["std", "help"] }
|
||||
completest = "0.4.0"
|
||||
completest-nu = "0.4.0"
|
||||
|
|
|
@ -243,8 +243,8 @@ pub fn value_hint_command(name: &'static str) -> Command {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn assert_matches_path(
|
||||
expected_path: impl AsRef<std::path::Path>,
|
||||
pub fn assert_matches(
|
||||
expected: impl Into<snapbox::Data>,
|
||||
gen: impl clap_complete::Generator,
|
||||
mut cmd: clap::Command,
|
||||
name: &'static str,
|
||||
|
@ -253,9 +253,9 @@ pub fn assert_matches_path(
|
|||
clap_complete::generate(gen, &mut cmd, name, &mut buf);
|
||||
|
||||
snapbox::Assert::new()
|
||||
.action_env("SNAPSHOTS")
|
||||
.action_env(snapbox::DEFAULT_ACTION_ENV)
|
||||
.normalize_paths(false)
|
||||
.matches_path(expected_path, buf);
|
||||
.matches(expected, buf);
|
||||
}
|
||||
|
||||
pub fn register_example<R: completest::RuntimeBuilder>(context: &str, name: &str) {
|
||||
|
|
|
@ -4,8 +4,8 @@ mod common;
|
|||
fn basic() {
|
||||
let name = "my-app";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/basic.nu",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/basic.nu"],
|
||||
clap_complete_nushell::Nushell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -16,8 +16,8 @@ fn basic() {
|
|||
fn feature_sample() {
|
||||
let name = "my-app";
|
||||
let cmd = common::feature_sample_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/feature_sample.nu",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/feature_sample.nu"],
|
||||
clap_complete_nushell::Nushell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -28,8 +28,8 @@ fn feature_sample() {
|
|||
fn special_commands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::special_commands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/special_commands.nu",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/special_commands.nu"],
|
||||
clap_complete_nushell::Nushell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -40,8 +40,8 @@ fn special_commands() {
|
|||
fn quoting() {
|
||||
let name = "my-app";
|
||||
let cmd = common::quoting_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/quoting.nu",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/quoting.nu"],
|
||||
clap_complete_nushell::Nushell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -52,8 +52,8 @@ fn quoting() {
|
|||
fn aliases() {
|
||||
let name = "my-app";
|
||||
let cmd = common::aliases_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/aliases.nu",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/aliases.nu"],
|
||||
clap_complete_nushell::Nushell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -64,8 +64,8 @@ fn aliases() {
|
|||
fn sub_subcommands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::sub_subcommands_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/sub_subcommands.nu",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/sub_subcommands.nu"],
|
||||
clap_complete_nushell::Nushell,
|
||||
cmd,
|
||||
name,
|
||||
|
@ -76,8 +76,8 @@ fn sub_subcommands() {
|
|||
fn value_hint() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_hint_command(name);
|
||||
common::assert_matches_path(
|
||||
"tests/snapshots/value_hint.nu",
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/value_hint.nu"],
|
||||
clap_complete_nushell::Nushell,
|
||||
cmd,
|
||||
name,
|
||||
|
|
|
@ -36,7 +36,7 @@ roff = "0.2.1"
|
|||
clap = { path = "../", version = "4.0.0", default-features = false, features = ["std", "env"] }
|
||||
|
||||
[dev-dependencies]
|
||||
snapbox = { version = "0.4.16", features = ["diff"] }
|
||||
snapbox = { version = "0.5.0", features = ["diff"] }
|
||||
clap = { path = "../", version = "4.0.0", default-features = false, features = ["std", "help"] }
|
||||
|
||||
[features]
|
||||
|
|
|
@ -272,13 +272,14 @@ pub fn env_value_command(name: &'static str) -> clap::Command {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn assert_matches_path(expected_path: impl AsRef<std::path::Path>, cmd: clap::Command) {
|
||||
pub fn assert_matches(expected: impl Into<snapbox::Data>, cmd: clap::Command) {
|
||||
let mut buf = vec![];
|
||||
clap_mangen::Man::new(cmd).render(&mut buf).unwrap();
|
||||
|
||||
snapbox::Assert::new()
|
||||
.action_env("SNAPSHOTS")
|
||||
.matches_path(expected_path, buf);
|
||||
.action_env(snapbox::DEFAULT_ACTION_ENV)
|
||||
.normalize_paths(false)
|
||||
.matches(expected, buf);
|
||||
}
|
||||
|
||||
pub fn possible_values_command(name: &'static str) -> clap::Command {
|
||||
|
|
|
@ -4,70 +4,70 @@ mod common;
|
|||
fn basic() {
|
||||
let name = "my-app";
|
||||
let cmd = common::basic_command(name);
|
||||
common::assert_matches_path("tests/snapshots/basic.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/basic.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn feature_sample() {
|
||||
let name = "my-app";
|
||||
let cmd = common::feature_sample_command(name);
|
||||
common::assert_matches_path("tests/snapshots/feature_sample.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/feature_sample.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn special_commands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::special_commands_command(name);
|
||||
common::assert_matches_path("tests/snapshots/special_commands.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/special_commands.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quoting() {
|
||||
let name = "my-app";
|
||||
let cmd = common::quoting_command(name);
|
||||
common::assert_matches_path("tests/snapshots/quoting.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/quoting.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aliases() {
|
||||
let name = "my-app";
|
||||
let cmd = common::aliases_command(name);
|
||||
common::assert_matches_path("tests/snapshots/aliases.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/aliases.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sub_subcommands() {
|
||||
let name = "my-app";
|
||||
let cmd = common::sub_subcommands_command(name);
|
||||
common::assert_matches_path("tests/snapshots/sub_subcommands.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/sub_subcommands.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn value_hint() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_hint_command(name);
|
||||
common::assert_matches_path("tests/snapshots/value_hint.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/value_hint.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hidden_options() {
|
||||
let name = "my-app";
|
||||
let cmd = common::hidden_option_command(name);
|
||||
common::assert_matches_path("tests/snapshots/hidden_option.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/hidden_option.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn value_env() {
|
||||
let name = "my-app";
|
||||
let cmd = common::env_value_command(name);
|
||||
common::assert_matches_path("tests/snapshots/value_env.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/value_env.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn possible_values() {
|
||||
let name = "my-app";
|
||||
let cmd = common::possible_values_command(name);
|
||||
common::assert_matches_path("tests/snapshots/possible_values.bash.roff", cmd);
|
||||
common::assert_matches(snapbox::file!["snapshots/possible_values.bash.roff"], cmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -80,7 +80,10 @@ fn sub_subcommands_help() {
|
|||
.find(|cmd| cmd.get_display_name() == Some("my-app-help"));
|
||||
assert!(cmd.is_some(), "help subcommand not found in command");
|
||||
if let Some(cmd) = cmd {
|
||||
common::assert_matches_path("tests/snapshots/sub_subcommand_help.roff", cmd.clone());
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/sub_subcommand_help.roff"],
|
||||
cmd.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,5 +91,8 @@ fn sub_subcommands_help() {
|
|||
fn value_name_without_arg() {
|
||||
let name = "my-app";
|
||||
let cmd = common::value_name_without_arg(name);
|
||||
common::assert_matches_path("tests/snapshots/value_name_without_arg.bash.roff", cmd);
|
||||
common::assert_matches(
|
||||
snapbox::file!["snapshots/value_name_without_arg.bash.roff"],
|
||||
cmd,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app 3.0"
|
||||
.SH NAME
|
||||
my/-app /- testing bash completions
|
||||
my\-app \- testing bash completions
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-f/fR|/fB/-/-flag/fR] [/fB/-o/fR|/fB/-/-option/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIpositional/fR]
|
||||
\fBmy\-app\fR [\fB\-f\fR|\fB\-\-flag\fR] [\fB\-o\fR|\fB\-\-option\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIpositional\fR]
|
||||
.SH DESCRIPTION
|
||||
testing bash completions
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-f/fR, /fB/-/-flag/fR
|
||||
\fB\-f\fR, \fB\-\-flag\fR
|
||||
cmd flag
|
||||
.TP
|
||||
/fB/-o/fR, /fB/-/-option/fR
|
||||
\fB\-o\fR, \fB\-\-option\fR
|
||||
cmd option
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
.TP
|
||||
/fB/-V/fR, /fB/-/-version/fR
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version
|
||||
.TP
|
||||
[/fIpositional/fR]
|
||||
[\fIpositional\fR]
|
||||
|
||||
.SH VERSION
|
||||
v3.0
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app "
|
||||
.SH NAME
|
||||
my/-app
|
||||
my\-app
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-c /fR] [/fB/-v /fR] [/fB/-h/fR|/fB/-/-help/fR] [/fIsubcommands/fR]
|
||||
\fBmy\-app\fR [\fB\-c \fR] [\fB\-v \fR] [\fB\-h\fR|\fB\-\-help\fR] [\fIsubcommands\fR]
|
||||
.SH DESCRIPTION
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-c/fR
|
||||
\fB\-c\fR
|
||||
|
||||
.TP
|
||||
/fB/-v/fR
|
||||
\fB\-v\fR
|
||||
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
my/-app/-test(1)
|
||||
my\-app\-test(1)
|
||||
Subcommand
|
||||
.TP
|
||||
my/-app/-help(1)
|
||||
my\-app\-help(1)
|
||||
Print this message or the help of the given subcommand(s)
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app 3.0"
|
||||
.SH NAME
|
||||
my/-app /- Tests completions
|
||||
my\-app \- Tests completions
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
|
||||
\fBmy\-app\fR [\fB\-c\fR|\fB\-\-config\fR]... [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIfile\fR] [\fIchoice\fR] [\fIsubcommands\fR]
|
||||
.SH DESCRIPTION
|
||||
Tests completions
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-c/fR, /fB/-/-config/fR
|
||||
\fB\-c\fR, \fB\-\-config\fR
|
||||
some config file
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
.TP
|
||||
/fB/-V/fR, /fB/-/-version/fR
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version
|
||||
.TP
|
||||
[/fIfile/fR]
|
||||
[\fIfile\fR]
|
||||
some input file
|
||||
.TP
|
||||
[/fIchoice/fR]
|
||||
[\fIchoice\fR]
|
||||
|
||||
.br
|
||||
[/fIpossible values: /fRfirst, second]
|
||||
[\fIpossible values: \fRfirst, second]
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
my/-app/-test(1)
|
||||
my\-app\-test(1)
|
||||
tests things
|
||||
.TP
|
||||
my/-app/-help(1)
|
||||
my\-app\-help(1)
|
||||
Print this message or the help of the given subcommand(s)
|
||||
.SH VERSION
|
||||
v3.0
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app "
|
||||
.SH NAME
|
||||
my/-app
|
||||
my\-app
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-/-config/fR] [/fB/-h/fR|/fB/-/-help/fR]
|
||||
\fBmy\-app\fR [\fB\-\-config\fR] [\fB\-h\fR|\fB\-\-help\fR]
|
||||
.SH DESCRIPTION
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-/-config/fR
|
||||
\fB\-\-config\fR
|
||||
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app "
|
||||
.SH NAME
|
||||
my/-app
|
||||
my\-app
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-/-choice/fR] [/fB/-/-method/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fIpositional_choice/fR]
|
||||
\fBmy\-app\fR [\fB\-\-choice\fR] [\fB\-\-method\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fIpositional_choice\fR]
|
||||
.SH DESCRIPTION
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-/-choice/fR
|
||||
\fB\-\-choice\fR
|
||||
|
||||
.br
|
||||
[/fIpossible values: /fRbash, fish, zsh]
|
||||
[\fIpossible values: \fRbash, fish, zsh]
|
||||
.TP
|
||||
/fB/-/-method/fR
|
||||
\fB\-\-method\fR
|
||||
|
||||
.br
|
||||
/fIPossible values:/fR
|
||||
\fIPossible values:\fR
|
||||
.RS 14
|
||||
.IP /(bu 2
|
||||
.IP \(bu 2
|
||||
fast: use the Fast method
|
||||
.IP /(bu 2
|
||||
.IP \(bu 2
|
||||
slow: use the slow method
|
||||
.RE
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
Print help (see a summary with /*(Aq/-h/*(Aq)
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help (see a summary with \*(Aq\-h\*(Aq)
|
||||
.TP
|
||||
[/fIpositional_choice/fR]
|
||||
[\fIpositional_choice\fR]
|
||||
Pick the Position you want the command to run in
|
||||
.br
|
||||
|
||||
.br
|
||||
/fIPossible values:/fR
|
||||
\fIPossible values:\fR
|
||||
.RS 14
|
||||
.IP /(bu 2
|
||||
.IP \(bu 2
|
||||
left: run left adjusted
|
||||
.IP /(bu 2
|
||||
.IP \(bu 2
|
||||
right
|
||||
.RE
|
||||
|
|
|
@ -1,57 +1,57 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app 3.0"
|
||||
.SH NAME
|
||||
my/-app
|
||||
my\-app
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-/-single/-quotes/fR] [/fB/-/-double/-quotes/fR] [/fB/-/-backticks/fR] [/fB/-/-backslash/fR] [/fB/-/-brackets/fR] [/fB/-/-expansions/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIsubcommands/fR]
|
||||
\fBmy\-app\fR [\fB\-\-single\-quotes\fR] [\fB\-\-double\-quotes\fR] [\fB\-\-backticks\fR] [\fB\-\-backslash\fR] [\fB\-\-brackets\fR] [\fB\-\-expansions\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIsubcommands\fR]
|
||||
.SH DESCRIPTION
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-/-single/-quotes/fR
|
||||
Can be /*(Aqalways/*(Aq, /*(Aqauto/*(Aq, or /*(Aqnever/*(Aq
|
||||
\fB\-\-single\-quotes\fR
|
||||
Can be \*(Aqalways\*(Aq, \*(Aqauto\*(Aq, or \*(Aqnever\*(Aq
|
||||
.TP
|
||||
/fB/-/-double/-quotes/fR
|
||||
\fB\-\-double\-quotes\fR
|
||||
Can be "always", "auto", or "never"
|
||||
.TP
|
||||
/fB/-/-backticks/fR
|
||||
\fB\-\-backticks\fR
|
||||
For more information see `echo test`
|
||||
.TP
|
||||
/fB/-/-backslash/fR
|
||||
Avoid /*(Aq//n/*(Aq
|
||||
\fB\-\-backslash\fR
|
||||
Avoid \*(Aq\\n\*(Aq
|
||||
.TP
|
||||
/fB/-/-brackets/fR
|
||||
\fB\-\-brackets\fR
|
||||
List packages [filter]
|
||||
.TP
|
||||
/fB/-/-expansions/fR
|
||||
\fB\-\-expansions\fR
|
||||
Execute the shell command with $SHELL
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
.TP
|
||||
/fB/-V/fR, /fB/-/-version/fR
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
my/-app/-cmd/-single/-quotes(1)
|
||||
Can be /*(Aqalways/*(Aq, /*(Aqauto/*(Aq, or /*(Aqnever/*(Aq
|
||||
my\-app\-cmd\-single\-quotes(1)
|
||||
Can be \*(Aqalways\*(Aq, \*(Aqauto\*(Aq, or \*(Aqnever\*(Aq
|
||||
.TP
|
||||
my/-app/-cmd/-double/-quotes(1)
|
||||
my\-app\-cmd\-double\-quotes(1)
|
||||
Can be "always", "auto", or "never"
|
||||
.TP
|
||||
my/-app/-cmd/-backticks(1)
|
||||
my\-app\-cmd\-backticks(1)
|
||||
For more information see `echo test`
|
||||
.TP
|
||||
my/-app/-cmd/-backslash(1)
|
||||
Avoid /*(Aq//n/*(Aq
|
||||
my\-app\-cmd\-backslash(1)
|
||||
Avoid \*(Aq\\n\*(Aq
|
||||
.TP
|
||||
my/-app/-cmd/-brackets(1)
|
||||
my\-app\-cmd\-brackets(1)
|
||||
List packages [filter]
|
||||
.TP
|
||||
my/-app/-cmd/-expansions(1)
|
||||
my\-app\-cmd\-expansions(1)
|
||||
Execute the shell command with $SHELL
|
||||
.TP
|
||||
my/-app/-help(1)
|
||||
my\-app\-help(1)
|
||||
Print this message or the help of the given subcommand(s)
|
||||
.SH VERSION
|
||||
v3.0
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app 3.0"
|
||||
.SH NAME
|
||||
my/-app /- Tests completions
|
||||
my\-app \- Tests completions
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
|
||||
\fBmy\-app\fR [\fB\-c\fR|\fB\-\-config\fR]... [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIfile\fR] [\fIchoice\fR] [\fIsubcommands\fR]
|
||||
.SH DESCRIPTION
|
||||
Tests completions
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-c/fR, /fB/-/-config/fR
|
||||
\fB\-c\fR, \fB\-\-config\fR
|
||||
some config file
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
.TP
|
||||
/fB/-V/fR, /fB/-/-version/fR
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version
|
||||
.TP
|
||||
[/fIfile/fR]
|
||||
[\fIfile\fR]
|
||||
some input file
|
||||
.TP
|
||||
[/fIchoice/fR]
|
||||
[\fIchoice\fR]
|
||||
|
||||
.br
|
||||
[/fIpossible values: /fRfirst, second]
|
||||
[\fIpossible values: \fRfirst, second]
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
my/-app/-test(1)
|
||||
my\-app\-test(1)
|
||||
tests things
|
||||
.TP
|
||||
my/-app/-some_cmd(1)
|
||||
my\-app\-some_cmd(1)
|
||||
tests other things
|
||||
.TP
|
||||
my/-app/-some/-cmd/-with/-hyphens(1)
|
||||
my\-app\-some\-cmd\-with\-hyphens(1)
|
||||
.TP
|
||||
my/-app/-help(1)
|
||||
my\-app\-help(1)
|
||||
Print this message or the help of the given subcommand(s)
|
||||
.SH VERSION
|
||||
v3.0
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app-help 1 "help "
|
||||
.SH NAME
|
||||
my/-app/-help /- Print this message or the help of the given subcommand(s)
|
||||
my\-app\-help \- Print this message or the help of the given subcommand(s)
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app help/fR [/fIsubcommands/fR]
|
||||
\fBmy\-app help\fR [\fIsubcommands\fR]
|
||||
.SH DESCRIPTION
|
||||
Print this message or the help of the given subcommand(s)
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
my/-app/-help/-test(1)
|
||||
my\-app\-help\-test(1)
|
||||
tests things
|
||||
.TP
|
||||
my/-app/-help/-some_cmd(1)
|
||||
my\-app\-help\-some_cmd(1)
|
||||
top level subcommand
|
||||
.TP
|
||||
my/-app/-help/-help(1)
|
||||
my\-app\-help\-help(1)
|
||||
Print this message or the help of the given subcommand(s)
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app 3.0"
|
||||
.SH NAME
|
||||
my/-app /- Tests completions
|
||||
my\-app \- Tests completions
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
|
||||
\fBmy\-app\fR [\fB\-c\fR|\fB\-\-config\fR]... [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIfile\fR] [\fIchoice\fR] [\fIsubcommands\fR]
|
||||
.SH DESCRIPTION
|
||||
Tests completions
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-c/fR, /fB/-/-config/fR
|
||||
\fB\-c\fR, \fB\-\-config\fR
|
||||
some config file
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
.TP
|
||||
/fB/-V/fR, /fB/-/-version/fR
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version
|
||||
.TP
|
||||
[/fIfile/fR]
|
||||
[\fIfile\fR]
|
||||
some input file
|
||||
.TP
|
||||
[/fIchoice/fR]
|
||||
[\fIchoice\fR]
|
||||
|
||||
.br
|
||||
[/fIpossible values: /fRfirst, second]
|
||||
[\fIpossible values: \fRfirst, second]
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
my/-app/-test(1)
|
||||
my\-app\-test(1)
|
||||
tests things
|
||||
.TP
|
||||
my/-app/-some_cmd(1)
|
||||
my\-app\-some_cmd(1)
|
||||
top level subcommand
|
||||
.TP
|
||||
my/-app/-help(1)
|
||||
my\-app\-help(1)
|
||||
Print this message or the help of the given subcommand(s)
|
||||
.SH VERSION
|
||||
v3.0
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app "
|
||||
.SH NAME
|
||||
my/-app
|
||||
my\-app
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-c /fR] [/fB/-h/fR|/fB/-/-help/fR]
|
||||
\fBmy\-app\fR [\fB\-c \fR] [\fB\-h\fR|\fB\-\-help\fR]
|
||||
.SH DESCRIPTION
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-c/fR [default: config.toml]
|
||||
\fB\-c\fR [default: config.toml]
|
||||
Set configuration file path
|
||||
.RS
|
||||
May also be specified with the /fBCONFIG_FILE/fR environment variable.
|
||||
May also be specified with the \fBCONFIG_FILE\fR environment variable.
|
||||
.RE
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
Print help (see a summary with /*(Aq/-h/*(Aq)
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help (see a summary with \*(Aq\-h\*(Aq)
|
||||
|
|
|
@ -1,56 +1,56 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app "
|
||||
.SH NAME
|
||||
my/-app
|
||||
my\-app
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-/-choice/fR] [/fB/-/-unknown/fR] [/fB/-/-other/fR] [/fB/-p/fR|/fB/-/-path/fR] [/fB/-f/fR|/fB/-/-file/fR] [/fB/-d/fR|/fB/-/-dir/fR] [/fB/-e/fR|/fB/-/-exe/fR] [/fB/-/-cmd/-name/fR] [/fB/-c/fR|/fB/-/-cmd/fR] [/fB/-u/fR|/fB/-/-user/fR] [/fB/-H/fR|/fB/-/-host/fR] [/fB/-/-url/fR] [/fB/-/-email/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fIcommand_with_args/fR]
|
||||
\fBmy\-app\fR [\fB\-\-choice\fR] [\fB\-\-unknown\fR] [\fB\-\-other\fR] [\fB\-p\fR|\fB\-\-path\fR] [\fB\-f\fR|\fB\-\-file\fR] [\fB\-d\fR|\fB\-\-dir\fR] [\fB\-e\fR|\fB\-\-exe\fR] [\fB\-\-cmd\-name\fR] [\fB\-c\fR|\fB\-\-cmd\fR] [\fB\-u\fR|\fB\-\-user\fR] [\fB\-H\fR|\fB\-\-host\fR] [\fB\-\-url\fR] [\fB\-\-email\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fIcommand_with_args\fR]
|
||||
.SH DESCRIPTION
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-/-choice/fR
|
||||
\fB\-\-choice\fR
|
||||
|
||||
.br
|
||||
[/fIpossible values: /fRbash, fish, zsh]
|
||||
[\fIpossible values: \fRbash, fish, zsh]
|
||||
.TP
|
||||
/fB/-/-unknown/fR
|
||||
\fB\-\-unknown\fR
|
||||
|
||||
.TP
|
||||
/fB/-/-other/fR
|
||||
\fB\-\-other\fR
|
||||
|
||||
.TP
|
||||
/fB/-p/fR, /fB/-/-path/fR
|
||||
\fB\-p\fR, \fB\-\-path\fR
|
||||
|
||||
.TP
|
||||
/fB/-f/fR, /fB/-/-file/fR
|
||||
\fB\-f\fR, \fB\-\-file\fR
|
||||
|
||||
.TP
|
||||
/fB/-d/fR, /fB/-/-dir/fR
|
||||
\fB\-d\fR, \fB\-\-dir\fR
|
||||
|
||||
.TP
|
||||
/fB/-e/fR, /fB/-/-exe/fR
|
||||
\fB\-e\fR, \fB\-\-exe\fR
|
||||
|
||||
.TP
|
||||
/fB/-/-cmd/-name/fR
|
||||
\fB\-\-cmd\-name\fR
|
||||
|
||||
.TP
|
||||
/fB/-c/fR, /fB/-/-cmd/fR
|
||||
\fB\-c\fR, \fB\-\-cmd\fR
|
||||
|
||||
.TP
|
||||
/fB/-u/fR, /fB/-/-user/fR
|
||||
\fB\-u\fR, \fB\-\-user\fR
|
||||
|
||||
.TP
|
||||
/fB/-H/fR, /fB/-/-host/fR
|
||||
\fB\-H\fR, \fB\-\-host\fR
|
||||
|
||||
.TP
|
||||
/fB/-/-url/fR
|
||||
\fB\-\-url\fR
|
||||
|
||||
.TP
|
||||
/fB/-/-email/fR
|
||||
\fB\-\-email\fR
|
||||
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
.TP
|
||||
[/fIcommand_with_args/fR]
|
||||
[\fIcommand_with_args\fR]
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
.ie /n(.g .ds Aq /(aq
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH my-app 1 "my-app "
|
||||
.SH NAME
|
||||
my/-app
|
||||
my\-app
|
||||
.SH SYNOPSIS
|
||||
/fBmy/-app/fR [/fB/-/-flag/fR] [/fB/-h/fR|/fB/-/-help/fR]
|
||||
\fBmy\-app\fR [\fB\-\-flag\fR] [\fB\-h\fR|\fB\-\-help\fR]
|
||||
.SH DESCRIPTION
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
/fB/-/-flag/fR
|
||||
\fB\-\-flag\fR
|
||||
|
||||
.TP
|
||||
/fB/-h/fR, /fB/-/-help/fR
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
|
|
|
@ -427,14 +427,16 @@ fn optional_value() {
|
|||
assert_eq!(m.get_one::<String>("port").unwrap(), "42");
|
||||
|
||||
let help = cmd.render_help().to_string();
|
||||
const HELP: &str = "\
|
||||
Usage: test [OPTIONS]
|
||||
snapbox::assert_eq(
|
||||
snapbox::str![[r#"
|
||||
Usage: test [OPTIONS]
|
||||
|
||||
Options:
|
||||
-p [<NUM>]
|
||||
-h, --help Print help
|
||||
";
|
||||
snapbox::assert_eq(HELP, help);
|
||||
Options:
|
||||
-p [<NUM>]
|
||||
-h, --help Print help
|
||||
"#]],
|
||||
help,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -230,18 +230,6 @@ For more information, try '--help'.
|
|||
|
||||
#[test]
|
||||
fn derive_order_next_order() {
|
||||
static HELP: &str = "\
|
||||
Usage: test [OPTIONS]
|
||||
|
||||
Options:
|
||||
--flag-b first flag
|
||||
--option-b <OPTION_B> first option
|
||||
-h, --help Print help
|
||||
-V, --version Print version
|
||||
--flag-a second flag
|
||||
--option-a <OPTION_A> second option
|
||||
";
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "test", version = "1.2")]
|
||||
struct Args {
|
||||
|
@ -277,23 +265,24 @@ Options:
|
|||
let mut cmd = Args::command();
|
||||
|
||||
let help = cmd.render_help().to_string();
|
||||
snapbox::assert_eq(HELP, help);
|
||||
snapbox::assert_eq(
|
||||
snapbox::str![[r#"
|
||||
Usage: test [OPTIONS]
|
||||
|
||||
Options:
|
||||
--flag-b first flag
|
||||
--option-b <OPTION_B> first option
|
||||
-h, --help Print help
|
||||
-V, --version Print version
|
||||
--flag-a second flag
|
||||
--option-a <OPTION_A> second option
|
||||
"#]],
|
||||
help,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn derive_order_next_order_flatten() {
|
||||
static HELP: &str = "\
|
||||
Usage: test [OPTIONS]
|
||||
|
||||
Options:
|
||||
--flag-b first flag
|
||||
--option-b <OPTION_B> first option
|
||||
-h, --help Print help
|
||||
-V, --version Print version
|
||||
--flag-a second flag
|
||||
--option-a <OPTION_A> second option
|
||||
";
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "test", version = "1.2")]
|
||||
struct Args {
|
||||
|
@ -329,7 +318,20 @@ Options:
|
|||
let mut cmd = Args::command();
|
||||
|
||||
let help = cmd.render_help().to_string();
|
||||
snapbox::assert_eq(HELP, help);
|
||||
snapbox::assert_eq(
|
||||
snapbox::str![[r#"
|
||||
Usage: test [OPTIONS]
|
||||
|
||||
Options:
|
||||
--flag-b first flag
|
||||
--option-b <OPTION_B> first option
|
||||
-h, --help Print help
|
||||
-V, --version Print version
|
||||
--flag-a second flag
|
||||
--option-a <OPTION_A> second option
|
||||
"#]],
|
||||
help,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -301,14 +301,16 @@ mod arg {
|
|||
|
||||
let mut help = Vec::new();
|
||||
cmd.write_help(&mut help).unwrap();
|
||||
const HELP: &str = "\
|
||||
snapbox::assert_eq(
|
||||
snapbox::str![["\
|
||||
Usage: test [OPTIONS]
|
||||
|
||||
Options:
|
||||
-p [<NUM>]
|
||||
-h, --help Print help information
|
||||
";
|
||||
snapbox::assert_eq(HELP, help);
|
||||
"]],
|
||||
help,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue