Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
shikhar committed Nov 7, 2024
1 parent 4670074 commit 2fc36fc
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn config_path() -> Result<PathBuf, S2CliError> {
pub fn load_config(path: &Path) -> Result<S2Config, S2ConfigError> {
Config::builder()
.add_source(config::File::new(
path.to_str().ok_or(S2ConfigError::PathError)?,
path.to_str().expect("config path is valid utf8"),
FileFormat::Toml,
))
.add_source(config::Environment::with_prefix("S2"))
Expand All @@ -57,12 +57,9 @@ pub fn create_config(config_path: &PathBuf, auth_token: String) -> Result<(), S2

#[derive(Error, Debug, Diagnostic)]
pub enum S2ConfigError {
#[error("Failed to find config directory")]
#[error("Failed to find a home for config directory")]
DirNotFound,

#[error("Failed to find config file")]
PathError,

#[error("Failed to load config file")]
#[diagnostic(help(
"Did you run `s2-cli config set`? or use `S2_AUTH_TOKEN` environment variable."
Expand Down

0 comments on commit 2fc36fc

Please sign in to comment.