schema_registry_cli/settings/
completion.rs1use std::path::PathBuf;
2
3use clap::Args;
4use clap_complete::Shell;
5
6#[derive(Debug, Clone, PartialEq, Args)]
8pub struct Completion {
9 pub shell: Shell,
11
12 #[clap(short, long)]
14 pub out_dir: Option<PathBuf>,
15}
16
17#[cfg(test)]
18mod tests {
19 use assert2::check;
20 use clap::Parser;
21
22 use super::*;
23
24 #[derive(Debug, Parser)]
25 struct JustCompletion {
26 #[clap(flatten)]
27 command: Completion,
28 }
29
30 #[rstest::rstest]
31 #[case(&["bin", "zsh"], Completion {
32 shell: Shell::Zsh,
33 out_dir: None,
34 })]
35 #[case(&["bin", "zsh", "--out-dir", "~/.zfunc"], Completion {
36 shell: Shell::Zsh,
37 out_dir: Some(PathBuf::from("~/.zfunc")),
38 })]
39 #[case(&["bin", "zsh", "-o", "~/.zfunc"], Completion {
40 shell: Shell::Zsh,
41 out_dir: Some(PathBuf::from("~/.zfunc")),
42 })]
43 fn should_parse_schema(#[case] args: &[&str], #[case] expected: Completion) {
44 let result = JustCompletion::parse_from(args);
45 check!(result.command == expected);
46 }
47}