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")
|
Arg::with_name("category")
|
||||||
.help("Show all notes from a category/date.")
|
.help("Show all notes from a category/date.")
|
||||||
.short("c")
|
.short("c")
|
||||||
.long("category")
|
.long("category"),
|
||||||
.conflicts_with("name"),
|
|
||||||
)
|
)
|
||||||
.arg(Arg::with_name("name").help("Name of the note.")),
|
.arg(Arg::with_name("name").help("Name of the note.")),
|
||||||
)
|
)
|
||||||
|
@ -112,27 +112,28 @@ pub fn search(matches: &ArgMatches) -> Result<()> {
|
|||||||
|
|
||||||
/// Process argument `show`.
|
/// Process argument `show`.
|
||||||
pub fn show(matches: &ArgMatches) -> Result<()> {
|
pub fn show(matches: &ArgMatches) -> Result<()> {
|
||||||
match matches.value_of("name") {
|
if matches.is_present("all") {
|
||||||
Some(s) => notes::show(s)?,
|
return notes::show_all();
|
||||||
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 => {
|
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())
|
let s: String = Input::with_theme(&ColorfulTheme::default())
|
||||||
.with_prompt("String to search")
|
.with_prompt("String to search")
|
||||||
.interact_text()?;
|
.interact_text()?;
|
||||||
notes::show(&s)?;
|
return notes::show(&s);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process argument `panic`.
|
/// Process argument `panic`.
|
||||||
|
Loading…
Reference in New Issue
Block a user