Skip to content

Commit 9431376

Browse files
authored
rust(fix): config create on existing config errors nicely (#557)
1 parent d1cbf7e commit 9431376

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

rust/crates/sift_cli/src/cmd/config.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,22 @@ pub fn show() -> Result<ExitCode> {
2424
}
2525

2626
pub fn create() -> Result<ExitCode> {
27-
let (_, path) = create_config_file()?;
27+
let path = get_config_file_path()?;
2828
let p = path.display().to_string();
2929

30+
if metadata(&path).is_ok() {
31+
Output::new()
32+
.line(format!("A config file already exists at '{}'.", p.yellow()))
33+
.tip(format!(
34+
"Use '{}' to view the contents.",
35+
format!("{BIN_NAME} config show").green()
36+
))
37+
.print();
38+
return Ok(ExitCode::SUCCESS);
39+
}
40+
41+
create_config_file()?;
42+
3043
Output::new()
3144
.line(format!(
3245
"An empty config file has been created at '{}'.",

0 commit comments

Comments
 (0)