Skip to content

Commit

Permalink
Modify
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Jun 8, 2024
1 parent 0c1321d commit 012efa1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ pub(crate) enum Shell {
impl Shell {
pub(crate) fn script(self) -> RunResult<'static, String> {
match self {
completions::Shell::Bash => completions::clap(clap_complete::Shell::Bash),
completions::Shell::Elvish => completions::clap(clap_complete::Shell::Elvish),
completions::Shell::Fish => completions::clap(clap_complete::Shell::Fish),
completions::Shell::Nushell => Ok(completions::NUSHELL_COMPLETION_SCRIPT.into()),
completions::Shell::Powershell => completions::clap(clap_complete::Shell::PowerShell),
completions::Shell::Zsh => completions::clap(clap_complete::Shell::Zsh),
Self::Bash => completions::clap(clap_complete::Shell::Bash),
Self::Elvish => completions::clap(clap_complete::Shell::Elvish),
Self::Fish => completions::clap(clap_complete::Shell::Fish),
Self::Nushell => Ok(completions::NUSHELL_COMPLETION_SCRIPT.into()),
Self::Powershell => completions::clap(clap_complete::Shell::PowerShell),
Self::Zsh => completions::clap(clap_complete::Shell::Zsh),
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ impl Config {
.arg(
Arg::new(cmd::COMPLETIONS)
.long("completions")
.action(ArgAction::Append)
.num_args(1..)
.action(ArgAction::Set)
.value_name("SHELL")
.value_parser(value_parser!(completions::Shell))
.ignore_case(true)
Expand Down Expand Up @@ -1544,15 +1543,15 @@ mod tests {
}

error_matches! {
name: completions_arguments,
args: ["--completions", "zsh", "foo"],
name: completions_argument,
args: ["--completions", "foo"],
error: error,
check: {
assert_eq!(error.kind(), clap::error::ErrorKind::InvalidValue);
assert_eq!(error.context().collect::<Vec<_>>(), vec![
(
ContextKind::InvalidArg,
&ContextValue::String("--completions <SHELL>...".into())),
&ContextValue::String("--completions <SHELL>".into())),
(
ContextKind::InvalidValue,
&ContextValue::String("foo".into()),
Expand Down

0 comments on commit 012efa1

Please sign in to comment.