show category takes optional name argument
This way it follows logic of other subcommands.
This commit is contained in:
parent
1e4fb62369
commit
803748d956
@ -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.")),
|
||||
)
|
||||
|
@ -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)?;
|
||||
if matches.is_present("all") {
|
||||
return notes::show_all();
|
||||
}
|
||||
false => {
|
||||
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()?;
|
||||
notes::show(&s)?;
|
||||
return notes::show(&s);
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Process argument `panic`.
|
||||
|
Loading…
Reference in New Issue
Block a user