category prompt when creating new note

This commit is contained in:
fiplox 2021-05-31 18:00:34 +02:00
parent 48f04ab3d6
commit b717d6a832
1 changed files with 8 additions and 2 deletions

View File

@ -11,9 +11,15 @@ pub fn new(matches: &ArgMatches) -> Result<()> {
.with_prompt("Name of your note")
.interact_text()?,
};
let category = matches.value_of("category").unwrap_or("");
let category = match matches.value_of("category") {
Some(s) => s.to_owned(),
None => Input::with_theme(&ColorfulTheme::default())
.with_prompt("Category for your note")
.default("".to_string())
.interact_text()?,
};
notes::create(&header, category)?;
notes::create(&header, &category)?;
Ok(())
}