diff --git a/src/bin/gman/cli.rs b/src/bin/gman/cli.rs index e3a8f23..ed09b8a 100644 --- a/src/bin/gman/cli.rs +++ b/src/bin/gman/cli.rs @@ -280,6 +280,27 @@ pub fn run_config_completer(current: &OsStr) -> Vec { } } +pub fn provider_completer(current: &OsStr) -> Vec { + let cur = current.to_string_lossy(); + match load_config() { + Ok(config) => { + config.providers + .iter() + .filter(|pc| { + pc.name + .as_ref() + .expect("run config has no name") + .starts_with(&*cur) + }) + .map(|pc| { + CompletionCandidate::new(pc.name.as_ref().expect("provider has no name")) + }) + .collect() + } + Err(_) => vec![], + } +} + pub fn secrets_completer(current: &OsStr) -> Vec { let cur = current.to_string_lossy(); match load_config() { diff --git a/src/bin/gman/main.rs b/src/bin/gman/main.rs index 20e4587..e9181ed 100644 --- a/src/bin/gman/main.rs +++ b/src/bin/gman/main.rs @@ -1,3 +1,4 @@ +use crate::cli::provider_completer; use crate::cli::run_config_completer; use crate::cli::secrets_completer; use anyhow::{Context, Result}; @@ -51,7 +52,7 @@ struct Cli { output: Option, /// Specify the secret provider to use (defaults to 'default_provider' in config (usually 'local')) - #[arg(long, global = true, env = "GMAN_PROVIDER", value_parser = ["local", "aws_secrets_manager", "azure_key_vault", "gcp_secret_manager", "gopass"])] + #[arg(long, global = true, env = "GMAN_PROVIDER", add = ArgValueCompleter::new(provider_completer))] provider: Option, /// Specify a run profile to use when wrapping a command