Adds a little eye candy for the paths and listing

This commit is contained in:
Dandaedre 2023-05-23 19:04:04 +02:00
parent c4185e848a
commit 3c7f672a55
2 changed files with 8 additions and 7 deletions

View File

@ -39,19 +39,19 @@ impl fmt::Display for SnippetError {
}
SnippetError::NotFound(ref p) => write!(
f,
"The Snippet {:?} doesn't exists. Use -c to create it and/or -E to edit it.",p.file_name().unwrap(),
"The Snippet {} doesn't exists. Use -c to create it and/or -E to edit it.",p.file_name().unwrap().to_str().unwrap(),
),
SnippetError::NotFoundNoRetryError(ref p) => {
write!(
f,
"The Snippet {:?} doen't exists. Use -c to create it.",
p.file_name(),
"The Snippet {} doen't exists. Use -c to create it.",
p.file_name().unwrap().to_str().unwrap(),
)
}
SnippetError::FoundNoEraseError(ref p) => write!(
f,
"The Snippet {:?} already exists. Use -f/--force to overwrite it.",
p.file_name().unwrap(),
"The Snippet {} already exists. Use -f/--force to overwrite it.",
p.file_name().unwrap().to_str().unwrap(),
),
SnippetError::ReparsingError => write!(f,"The Snippet couldn't be re-parsed, it might be caused by a bad value in your edit. \nThe snipped was saved as a raw file instead but cant be used as is."),
SnippetError::IndexError(ref i) => write!(f,"An error occured while trying to access the index {} of the given arguments.\nThe default arguments for this command likely do not support {} arguments.",i,i+1),

View File

@ -160,7 +160,7 @@ pub fn edit_whole_snippet(cli: &Cli) -> Result<(), SnippetError> {
} else {
// No erasing/overriting
println!(
"The snippet could not be saved as {:}.yaml, as this Snippet already exists. The Snippet will be saved under it's original name name: {}",
"The snippet could not be saved as {}.yaml, as this Snippet already exists. The Snippet will be saved under it's original name name: {}",
snp.name,origin_p.file_name().unwrap().to_str().unwrap()
);
(File::create(&origin_p)?, origin_p)
@ -193,7 +193,7 @@ pub fn list_snippets(_cli: &Cli) -> Result<(), SnippetError> {
let dirpath = config_folder()?;
let paths = fs::read_dir(&dirpath).unwrap();
println!(
"Snippet list at {:?}:\n {:?}",
"Snippet list at {}:\n {}",
dirpath.parent().unwrap().to_str().unwrap(),
paths
.map(|p| p
@ -205,6 +205,7 @@ pub fn list_snippets(_cli: &Cli) -> Result<(), SnippetError> {
.unwrap()
.to_owned())
.collect::<Vec<String>>()
.join(", ")
);
Ok(())
}