check if there is notes before show

This commit is contained in:
Volodymyr Patuta 2021-01-18 15:14:12 +01:00
parent aa7924e693
commit 3b30f116cc
1 changed files with 6 additions and 0 deletions

View File

@ -278,6 +278,9 @@ pub fn show_all() -> Result<()> {
files.push(fs::read_to_string(file.path())?);
}
}
if files.is_empty() {
return Err(anyhow!("No notes found."));
}
let skin = show::make_skin();
let md = &files.join("---\n");
show::run_app(skin, md)?;
@ -313,6 +316,9 @@ pub fn show_category(category: &str) -> Result<()> {
files.push(fs::read_to_string(file.path())?);
}
}
if files.is_empty() {
return Err(anyhow!("No notes found."));
}
let skin = show::make_skin();
let md = &files.join("---\n");
show::run_app(skin, md)?;