diff options
author | Andy Freeland <andy@andyfreeland.net> | 2021-03-26 04:06:08 +0000 |
---|---|---|
committer | Andy Freeland <andy@andyfreeland.net> | 2021-03-28 17:29:14 +0000 |
commit | a389db173b8b6f38c8330ddecf00023c72c8ee86 (patch) | |
tree | 7203940e7885d97197bbc7f09dbe83a1994a5e8b /tests/cli.rs | |
parent | Merge pull request #475 from svenstaro/dependabot/cargo/serde-1.0.125 (diff) | |
download | miniserve-a389db173b8b6f38c8330ddecf00023c72c8ee86.tar.gz miniserve-a389db173b8b6f38c8330ddecf00023c72c8ee86.zip |
Generate completions with `miniserve --print-completions <shell>`
This patch adds a `--print-completions` option to generate shell
completion files at runtime. This ensures the completions are always up
to date.
Fixes #377.
Diffstat (limited to 'tests/cli.rs')
-rw-r--r-- | tests/cli.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/cli.rs b/tests/cli.rs index e09473d..f88b284 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -3,7 +3,7 @@ mod fixtures; use assert_cmd::prelude::*; use fixtures::Error; use std::process::Command; -use structopt::clap::{crate_name, crate_version}; +use structopt::clap::{crate_name, crate_version, Shell}; #[test] /// Show help and exit. @@ -27,3 +27,29 @@ fn version_shows() -> Result<(), Error> { Ok(()) } + +#[test] +/// Print completions and exit. +fn print_completions() -> Result<(), Error> { + for shell in &Shell::variants() { + Command::cargo_bin("miniserve")? + .arg("--print-completions") + .arg(&shell) + .assert() + .success(); + } + + Ok(()) +} + +#[test] +/// Print completions rejects invalid shells. +fn print_completions_invalid_shell() -> Result<(), Error> { + Command::cargo_bin("miniserve")? + .arg("--print-completions") + .arg("fakeshell") + .assert() + .failure(); + + Ok(()) +} |