Skip to content

Commit

Permalink
refactor(cli): simplify check for completions cli args
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Sep 8, 2023
1 parent a8d2436 commit 0b2ded4
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions packages_rs/nextclade-cli/src/cli/nextclade_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ lazy_static! {
pub static ref SHELLS: Vec<&'static str> = ["bash", "elvish", "fish", "fig", "powershell", "zsh"].to_vec();
}

pub fn check_shells(value: &str) -> Result<String, Report> {
SHELLS
.contains(&value)
.then_some(value.to_owned())
.ok_or_else(|| eyre!("Unknown shell: '{value}'. Possible values: {}", SHELLS.join(", ")))
}

#[derive(Parser, Debug)]
#[clap(name = "nextclade")]
#[clap(author, version)]
Expand Down Expand Up @@ -69,7 +62,7 @@ pub enum NextcladeCommands {
///
Completions {
/// Name of the shell to generate appropriate completions
#[clap(value_name = "SHELL", default_value_t = String::from("bash"), value_parser = check_shells)]
#[clap(value_name = "SHELL", default_value_t = String::from("bash"), value_parser = SHELLS.clone())]
shell: String,
},

Expand Down

0 comments on commit 0b2ded4

Please sign in to comment.