Skip to content

Commit 21da46d

Browse files
committed
chore: add error handling on template name
1 parent fb91448 commit 21da46d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/utils.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ impl Cloup {
9494
ErrorKind::PermissionDenied => {
9595
eprintln!("Permission denied when creating config directory")
9696
}
97-
ErrorKind::AlreadyExists => {
98-
eprintln!("Config directory already exists")
99-
}
10097
_ => (),
10198
}
10299
}
@@ -108,12 +105,19 @@ impl Cloup {
108105
format!("template_dir={:?}", current_dir),
109106
)
110107
.expect("An error occurred when writing config file");
108+
109+
println!("📚 Successfully made this the template directory for cloups");
111110
}
112111

113112
pub fn create(&self, name: &str, files: Vec<String>) {
114113
let current_dir = &self.current_dir;
115114
let template_dir = self.template_dir.join(&name);
116115

116+
if name.starts_with('.') {
117+
eprintln!("Name of template should not start with a dot");
118+
process::exit(1);
119+
}
120+
117121
if fs::create_dir(&template_dir).is_err() {
118122
eprintln!("Template {} already exists", &name.bright_purple());
119123
process::exit(1);

0 commit comments

Comments
 (0)