diff --git a/src/rnote/app.rs b/src/rnote/app.rs index fe40cdf..0ff21f0 100644 --- a/src/rnote/app.rs +++ b/src/rnote/app.rs @@ -92,8 +92,7 @@ pub fn make_app() -> App<'static, 'static> { Arg::with_name("category") .help("Show all notes from a category/date.") .short("c") - .long("category") - .conflicts_with("name"), + .long("category"), ) .arg(Arg::with_name("name").help("Name of the note.")), ) diff --git a/src/rnote/process.rs b/src/rnote/process.rs index 3ca5ea8..cbc5db5 100644 --- a/src/rnote/process.rs +++ b/src/rnote/process.rs @@ -112,27 +112,28 @@ pub fn search(matches: &ArgMatches) -> Result<()> { /// Process argument `show`. pub fn show(matches: &ArgMatches) -> Result<()> { - match matches.value_of("name") { - Some(s) => notes::show(s)?, - None => match matches.is_present("all") { - true => notes::show_all()?, - false => match matches.is_present("category") { - true => { - let category: String = Input::with_theme(&ColorfulTheme::default()) - .with_prompt("Name of category:") - .interact_text()?; - notes::show_category(&category)?; - } - false => { - let s: String = Input::with_theme(&ColorfulTheme::default()) - .with_prompt("String to search") - .interact_text()?; - notes::show(&s)?; - } - }, - }, + if matches.is_present("all") { + return notes::show_all(); + } + if matches.is_present("category") { + let category: String = match matches.value_of("name") { + Some(s) => s.to_string(), + None => Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Category:") + .interact_text()?, + }; + return notes::show_category(&category); + } + + match matches.value_of("name") { + Some(s) => return notes::show(s), + None => { + let s: String = Input::with_theme(&ColorfulTheme::default()) + .with_prompt("String to search") + .interact_text()?; + return notes::show(&s); + } } - Ok(()) } /// Process argument `panic`.