diff --git a/src/bin/gman/main.rs b/src/bin/gman/main.rs index 929f037..f03a57c 100644 --- a/src/bin/gman/main.rs +++ b/src/bin/gman/main.rs @@ -70,7 +70,7 @@ struct Cli { provider: Option, /// Specify a run profile to use when wrapping a command - #[arg(long)] + #[arg(long, short)] profile: Option, /// Output the command that will be run instead of executing it @@ -95,7 +95,8 @@ enum Commands { name: String, }, - /// Update an existing secret in the configured secret provider + /// Update an existing secret in the configured secret provider (if supported by the provider) + /// If a provider does not support updating secrets, this command will return an error. Update { /// Name of the secret to update name: String, diff --git a/src/providers/mod.rs b/src/providers/mod.rs index 96f9bf9..0697fe0 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -1,21 +1,31 @@ -pub mod local; mod git_sync; +pub mod local; use crate::config::Config; use crate::providers::local::LocalProvider; -use anyhow::Result; -use serde::{Deserialize}; +use anyhow::{Result, anyhow}; +use serde::Deserialize; use std::fmt::{Display, Formatter}; use std::str::FromStr; use thiserror::Error; pub trait SecretProvider { - fn name(&self) -> &'static str; + fn name(&self) -> &'static str; fn get_secret(&self, config: &Config, key: &str) -> Result; fn set_secret(&self, config: &Config, key: &str, value: &str) -> Result<()>; - fn update_secret(&self, config: &Config, key: &str, value: &str) -> Result<()>; + fn update_secret(&self, _config: &Config, _key: &str, _value: &str) -> Result<()> { + Err(anyhow!( + "update secret not supported for provider {}", + self.name() + )) + } fn delete_secret(&self, key: &str) -> Result<()>; - fn list_secrets(&self) -> Result>; + fn list_secrets(&self) -> Result> { + Err(anyhow!( + "list secrets is not supported for the provider {}", + self.name() + )) + } fn sync(&self, config: &mut Config) -> Result<()>; }