mirror of
https://github.com/clap-rs/clap
synced 2024-11-14 00:27:13 +00:00
9f9e410c6d
Inspired by argcomplete, this provides Rust-implemented completions - Only bash for now - No subcommand support - No flag value support - No special settings support - No handling of positions within positionals - No prioritizing of required or removing of conflicts (including self-conflicts)
101 lines
2.2 KiB
Rust
101 lines
2.2 KiB
Rust
mod common;
|
|
|
|
#[test]
|
|
fn basic() {
|
|
let name = "my-app";
|
|
let cmd = common::basic_command(name);
|
|
common::assert_matches_path(
|
|
"tests/snapshots/basic.bash",
|
|
clap_complete::shells::Bash,
|
|
cmd,
|
|
name,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn feature_sample() {
|
|
let name = "my-app";
|
|
let cmd = common::feature_sample_command(name);
|
|
common::assert_matches_path(
|
|
"tests/snapshots/feature_sample.bash",
|
|
clap_complete::shells::Bash,
|
|
cmd,
|
|
name,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn special_commands() {
|
|
let name = "my-app";
|
|
let cmd = common::special_commands_command(name);
|
|
common::assert_matches_path(
|
|
"tests/snapshots/special_commands.bash",
|
|
clap_complete::shells::Bash,
|
|
cmd,
|
|
name,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn quoting() {
|
|
let name = "my-app";
|
|
let cmd = common::quoting_command(name);
|
|
common::assert_matches_path(
|
|
"tests/snapshots/quoting.bash",
|
|
clap_complete::shells::Bash,
|
|
cmd,
|
|
name,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn aliases() {
|
|
let name = "my-app";
|
|
let cmd = common::aliases_command(name);
|
|
common::assert_matches_path(
|
|
"tests/snapshots/aliases.bash",
|
|
clap_complete::shells::Bash,
|
|
cmd,
|
|
name,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn sub_subcommands() {
|
|
let name = "my-app";
|
|
let cmd = common::sub_subcommands_command(name);
|
|
common::assert_matches_path(
|
|
"tests/snapshots/sub_subcommands.bash",
|
|
clap_complete::shells::Bash,
|
|
cmd,
|
|
name,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn value_hint() {
|
|
let name = "my-app";
|
|
let cmd = common::value_hint_command(name);
|
|
common::assert_matches_path(
|
|
"tests/snapshots/value_hint.bash",
|
|
clap_complete::shells::Bash,
|
|
cmd,
|
|
name,
|
|
);
|
|
}
|
|
|
|
#[cfg(feature = "unstable-dynamic")]
|
|
#[test]
|
|
fn register_minimal() {
|
|
let name = "my-app";
|
|
let executables = [name];
|
|
let completer = name;
|
|
let behavior = clap_complete::dynamic::bash::Behavior::Minimal;
|
|
|
|
let mut buf = Vec::new();
|
|
clap_complete::dynamic::bash::register(name, executables, completer, &behavior, &mut buf)
|
|
.unwrap();
|
|
snapbox::Assert::new()
|
|
.action_env("SNAPSHOTS")
|
|
.matches_path("tests/snapshots/register_minimal.bash", buf);
|
|
}
|