From 5f9cecb6bd3d39a5116b502fb560ffe19b949227 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 14 Feb 2024 16:44:57 -0600 Subject: [PATCH] chore: Update snapbox/trycmd --- Cargo.lock | 31 ++++++---- Cargo.toml | 4 +- clap_complete/Cargo.toml | 4 +- clap_complete/tests/testsuite/bash.rs | 48 ++++++++-------- clap_complete/tests/testsuite/common.rs | 8 +-- clap_complete/tests/testsuite/dynamic.rs | 30 ++++++---- clap_complete/tests/testsuite/elvish.rs | 50 +++++++++-------- clap_complete/tests/testsuite/fish.rs | 56 ++++++++++--------- clap_complete/tests/testsuite/powershell.rs | 44 +++++++-------- clap_complete/tests/testsuite/zsh.rs | 50 +++++++++-------- clap_complete_fig/Cargo.toml | 2 +- clap_complete_fig/tests/common.rs | 9 +-- clap_complete_fig/tests/fig.rs | 28 +++++----- .../tests/snapshots/quoting.fig.js | 12 ++-- clap_complete_nushell/Cargo.toml | 2 +- clap_complete_nushell/tests/common.rs | 8 +-- clap_complete_nushell/tests/nushell.rs | 28 +++++----- clap_mangen/Cargo.toml | 2 +- clap_mangen/tests/common.rs | 7 ++- clap_mangen/tests/roff.rs | 30 ++++++---- clap_mangen/tests/snapshots/aliases.bash.roff | 16 +++--- clap_mangen/tests/snapshots/basic.bash.roff | 16 +++--- .../tests/snapshots/feature_sample.bash.roff | 22 ++++---- .../tests/snapshots/hidden_option.bash.roff | 10 ++-- .../tests/snapshots/possible_values.bash.roff | 30 +++++----- clap_mangen/tests/snapshots/quoting.bash.roff | 44 +++++++-------- .../snapshots/special_commands.bash.roff | 26 ++++----- .../tests/snapshots/sub_subcommand_help.roff | 12 ++-- .../tests/snapshots/sub_subcommands.bash.roff | 24 ++++---- .../tests/snapshots/value_env.bash.roff | 14 ++--- .../tests/snapshots/value_hint.bash.roff | 38 ++++++------- .../value_name_without_arg.bash.roff | 10 ++-- tests/builder/multiple_values.rs | 16 +++--- tests/derive/help.rs | 54 +++++++++--------- tests/macros.rs | 8 ++- 35 files changed, 417 insertions(+), 376 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32cb38c9..d899aeb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml index 04385dfa..2fc1265f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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]] diff --git a/clap_complete/Cargo.toml b/clap_complete/Cargo.toml index 0f709bc7..1a245514 100644 --- a/clap_complete/Cargo.toml +++ b/clap_complete/Cargo.toml @@ -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"] } diff --git a/clap_complete/tests/testsuite/bash.rs b/clap_complete/tests/testsuite/bash.rs index 61f6ef12..590ea652 100644 --- a/clap_complete/tests/testsuite/bash.rs +++ b/clap_complete/tests/testsuite/bash.rs @@ -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); } diff --git a/clap_complete/tests/testsuite/common.rs b/clap_complete/tests/testsuite/common.rs index f7378cd0..a2f13f50 100644 --- a/clap_complete/tests/testsuite/common.rs +++ b/clap_complete/tests/testsuite/common.rs @@ -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, +pub fn assert_matches( + expected: impl Into, 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(context: &str, name: &str) { diff --git a/clap_complete/tests/testsuite/dynamic.rs b/clap_complete/tests/testsuite/dynamic.rs index 73897138..eeb3edf7 100644 --- a/clap_complete/tests/testsuite/dynamic.rs +++ b/clap_complete/tests/testsuite/dynamic.rs @@ -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]"), ); } diff --git a/clap_complete/tests/testsuite/elvish.rs b/clap_complete/tests/testsuite/elvish.rs index 7f16183d..1b7239b5 100644 --- a/clap_complete/tests/testsuite/elvish.rs +++ b/clap_complete/tests/testsuite/elvish.rs @@ -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::("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); } diff --git a/clap_complete/tests/testsuite/fish.rs b/clap_complete/tests/testsuite/fish.rs index ca6f40e4..3181e16e 100644 --- a/clap_complete/tests/testsuite/fish.rs +++ b/clap_complete/tests/testsuite/fish.rs @@ -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::("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); } diff --git a/clap_complete/tests/testsuite/powershell.rs b/clap_complete/tests/testsuite/powershell.rs index 6b8e4050..be7d0675 100644 --- a/clap_complete/tests/testsuite/powershell.rs +++ b/clap_complete/tests/testsuite/powershell.rs @@ -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, diff --git a/clap_complete/tests/testsuite/zsh.rs b/clap_complete/tests/testsuite/zsh.rs index 861b7a07..8b0104b8 100644 --- a/clap_complete/tests/testsuite/zsh.rs +++ b/clap_complete/tests/testsuite/zsh.rs @@ -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::("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); } diff --git a/clap_complete_fig/Cargo.toml b/clap_complete_fig/Cargo.toml index 7575308c..2b39d3b0 100644 --- a/clap_complete_fig/Cargo.toml +++ b/clap_complete_fig/Cargo.toml @@ -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"] } diff --git a/clap_complete_fig/tests/common.rs b/clap_complete_fig/tests/common.rs index 2f6d6608..afdf2a76 100644 --- a/clap_complete_fig/tests/common.rs +++ b/clap_complete_fig/tests/common.rs @@ -247,8 +247,8 @@ pub fn value_hint_command(name: &'static str) -> clap::Command { ) } -pub fn assert_matches_path( - expected_path: impl AsRef, +pub fn assert_matches( + expected: impl Into, 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); } diff --git a/clap_complete_fig/tests/fig.rs b/clap_complete_fig/tests/fig.rs index d93db7c8..60702f5a 100644 --- a/clap_complete_fig/tests/fig.rs +++ b/clap_complete_fig/tests/fig.rs @@ -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, diff --git a/clap_complete_fig/tests/snapshots/quoting.fig.js b/clap_complete_fig/tests/snapshots/quoting.fig.js index 81cb5273..31c244d2 100644 --- a/clap_complete_fig/tests/snapshots/quoting.fig.js +++ b/clap_complete_fig/tests/snapshots/quoting.fig.js @@ -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", diff --git a/clap_complete_nushell/Cargo.toml b/clap_complete_nushell/Cargo.toml index e0cbbcc0..ef9c6007 100644 --- a/clap_complete_nushell/Cargo.toml +++ b/clap_complete_nushell/Cargo.toml @@ -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" diff --git a/clap_complete_nushell/tests/common.rs b/clap_complete_nushell/tests/common.rs index fd7e9191..343e7307 100644 --- a/clap_complete_nushell/tests/common.rs +++ b/clap_complete_nushell/tests/common.rs @@ -243,8 +243,8 @@ pub fn value_hint_command(name: &'static str) -> Command { ) } -pub fn assert_matches_path( - expected_path: impl AsRef, +pub fn assert_matches( + expected: impl Into, 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(context: &str, name: &str) { diff --git a/clap_complete_nushell/tests/nushell.rs b/clap_complete_nushell/tests/nushell.rs index 1987fd70..f3eacd85 100644 --- a/clap_complete_nushell/tests/nushell.rs +++ b/clap_complete_nushell/tests/nushell.rs @@ -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, diff --git a/clap_mangen/Cargo.toml b/clap_mangen/Cargo.toml index aeaec75a..1671eed2 100644 --- a/clap_mangen/Cargo.toml +++ b/clap_mangen/Cargo.toml @@ -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] diff --git a/clap_mangen/tests/common.rs b/clap_mangen/tests/common.rs index 029098c0..90c48103 100644 --- a/clap_mangen/tests/common.rs +++ b/clap_mangen/tests/common.rs @@ -272,13 +272,14 @@ pub fn env_value_command(name: &'static str) -> clap::Command { ) } -pub fn assert_matches_path(expected_path: impl AsRef, cmd: clap::Command) { +pub fn assert_matches(expected: impl Into, 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 { diff --git a/clap_mangen/tests/roff.rs b/clap_mangen/tests/roff.rs index 38d1aef1..b96a54b3 100644 --- a/clap_mangen/tests/roff.rs +++ b/clap_mangen/tests/roff.rs @@ -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, + ); } diff --git a/clap_mangen/tests/snapshots/aliases.bash.roff b/clap_mangen/tests/snapshots/aliases.bash.roff index 10c6f441..e2c6f368 100644 --- a/clap_mangen/tests/snapshots/aliases.bash.roff +++ b/clap_mangen/tests/snapshots/aliases.bash.roff @@ -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 diff --git a/clap_mangen/tests/snapshots/basic.bash.roff b/clap_mangen/tests/snapshots/basic.bash.roff index ebacd859..d92a55fa 100644 --- a/clap_mangen/tests/snapshots/basic.bash.roff +++ b/clap_mangen/tests/snapshots/basic.bash.roff @@ -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) diff --git a/clap_mangen/tests/snapshots/feature_sample.bash.roff b/clap_mangen/tests/snapshots/feature_sample.bash.roff index b1a69336..6113bb88 100644 --- a/clap_mangen/tests/snapshots/feature_sample.bash.roff +++ b/clap_mangen/tests/snapshots/feature_sample.bash.roff @@ -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 diff --git a/clap_mangen/tests/snapshots/hidden_option.bash.roff b/clap_mangen/tests/snapshots/hidden_option.bash.roff index 84a375f4..fd2c8d1d 100644 --- a/clap_mangen/tests/snapshots/hidden_option.bash.roff +++ b/clap_mangen/tests/snapshots/hidden_option.bash.roff @@ -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 diff --git a/clap_mangen/tests/snapshots/possible_values.bash.roff b/clap_mangen/tests/snapshots/possible_values.bash.roff index e9768fdf..203d50ba 100644 --- a/clap_mangen/tests/snapshots/possible_values.bash.roff +++ b/clap_mangen/tests/snapshots/possible_values.bash.roff @@ -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 diff --git a/clap_mangen/tests/snapshots/quoting.bash.roff b/clap_mangen/tests/snapshots/quoting.bash.roff index 6097def8..77a9cf53 100644 --- a/clap_mangen/tests/snapshots/quoting.bash.roff +++ b/clap_mangen/tests/snapshots/quoting.bash.roff @@ -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 diff --git a/clap_mangen/tests/snapshots/special_commands.bash.roff b/clap_mangen/tests/snapshots/special_commands.bash.roff index 0be1869e..416e95c5 100644 --- a/clap_mangen/tests/snapshots/special_commands.bash.roff +++ b/clap_mangen/tests/snapshots/special_commands.bash.roff @@ -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 diff --git a/clap_mangen/tests/snapshots/sub_subcommand_help.roff b/clap_mangen/tests/snapshots/sub_subcommand_help.roff index 54fedca4..cf8ee958 100644 --- a/clap_mangen/tests/snapshots/sub_subcommand_help.roff +++ b/clap_mangen/tests/snapshots/sub_subcommand_help.roff @@ -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) diff --git a/clap_mangen/tests/snapshots/sub_subcommands.bash.roff b/clap_mangen/tests/snapshots/sub_subcommands.bash.roff index cafe26cd..09b577ad 100644 --- a/clap_mangen/tests/snapshots/sub_subcommands.bash.roff +++ b/clap_mangen/tests/snapshots/sub_subcommands.bash.roff @@ -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 diff --git a/clap_mangen/tests/snapshots/value_env.bash.roff b/clap_mangen/tests/snapshots/value_env.bash.roff index 37536d1c..3ff084d8 100644 --- a/clap_mangen/tests/snapshots/value_env.bash.roff +++ b/clap_mangen/tests/snapshots/value_env.bash.roff @@ -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) diff --git a/clap_mangen/tests/snapshots/value_hint.bash.roff b/clap_mangen/tests/snapshots/value_hint.bash.roff index 52193e1e..052422f9 100644 --- a/clap_mangen/tests/snapshots/value_hint.bash.roff +++ b/clap_mangen/tests/snapshots/value_hint.bash.roff @@ -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] diff --git a/clap_mangen/tests/snapshots/value_name_without_arg.bash.roff b/clap_mangen/tests/snapshots/value_name_without_arg.bash.roff index 2ffbe021..f6588c7a 100644 --- a/clap_mangen/tests/snapshots/value_name_without_arg.bash.roff +++ b/clap_mangen/tests/snapshots/value_name_without_arg.bash.roff @@ -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 diff --git a/tests/builder/multiple_values.rs b/tests/builder/multiple_values.rs index a3b19598..e00bdd04 100644 --- a/tests/builder/multiple_values.rs +++ b/tests/builder/multiple_values.rs @@ -427,14 +427,16 @@ fn optional_value() { assert_eq!(m.get_one::("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 [] - -h, --help Print help -"; - snapbox::assert_eq(HELP, help); + Options: + -p [] + -h, --help Print help + "#]], + help, + ); } #[test] diff --git a/tests/derive/help.rs b/tests/derive/help.rs index 8ae30c90..8caa880d 100644 --- a/tests/derive/help.rs +++ b/tests/derive/help.rs @@ -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 first option - -h, --help Print help - -V, --version Print version - --flag-a second flag - --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 first option + -h, --help Print help + -V, --version Print version + --flag-a second flag + --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 first option - -h, --help Print help - -V, --version Print version - --flag-a second flag - --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 first option + -h, --help Print help + -V, --version Print version + --flag-a second flag + --option-a second option + "#]], + help, + ); } #[test] diff --git a/tests/macros.rs b/tests/macros.rs index e95ea349..4c3e4c68 100644 --- a/tests/macros.rs +++ b/tests/macros.rs @@ -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 [] -h, --help Print help information -"; - snapbox::assert_eq(HELP, help); +"]], + help, + ); } }