From beaa8a81196b46cf954c5cd7dcb499f814173894 Mon Sep 17 00:00:00 2001 From: fiplox <56274824+fiplox@users.noreply.github.com> Date: Mon, 31 May 2021 20:53:07 +0200 Subject: [PATCH] get category name for "list" without prompt (from arg) --- src/rnote/app.rs | 1 + src/rnote/process.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/rnote/app.rs b/src/rnote/app.rs index f818924..8a52214 100644 --- a/src/rnote/app.rs +++ b/src/rnote/app.rs @@ -54,6 +54,7 @@ pub fn make_app() -> App<'static, 'static> { .alias("l") .alias("ls") .about("List all notes or notes from a category.") + .arg(Arg::with_name("name").help("Name of the category.")) .arg( Arg::with_name("category") .help("List all notes from a category.") diff --git a/src/rnote/process.rs b/src/rnote/process.rs index 0b249e4..cb49449 100644 --- a/src/rnote/process.rs +++ b/src/rnote/process.rs @@ -69,10 +69,13 @@ pub fn edit(matches: &ArgMatches) -> Result<()> { pub fn list(matches: &ArgMatches) -> Result<()> { match matches.is_present("category") { true => { - let s: String = Input::with_theme(&ColorfulTheme::default()) - .with_prompt("Category:") - .interact_text()?; - notes::list_category(&s)?; + let name: String = match matches.value_of("name") { + Some(s) => s.to_string(), + None => Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Category:") + .interact_text()?, + }; + notes::list_category(&name)?; } false => notes::list_all_notes()?, }