get category name for "list" without prompt (from arg)
This commit is contained in:
parent
56c4ed9011
commit
beaa8a8119
@ -54,6 +54,7 @@ pub fn make_app() -> App<'static, 'static> {
|
|||||||
.alias("l")
|
.alias("l")
|
||||||
.alias("ls")
|
.alias("ls")
|
||||||
.about("List all notes or notes from a category.")
|
.about("List all notes or notes from a category.")
|
||||||
|
.arg(Arg::with_name("name").help("Name of the category."))
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("category")
|
Arg::with_name("category")
|
||||||
.help("List all notes from a category.")
|
.help("List all notes from a category.")
|
||||||
|
@ -69,10 +69,13 @@ pub fn edit(matches: &ArgMatches) -> Result<()> {
|
|||||||
pub fn list(matches: &ArgMatches) -> Result<()> {
|
pub fn list(matches: &ArgMatches) -> Result<()> {
|
||||||
match matches.is_present("category") {
|
match matches.is_present("category") {
|
||||||
true => {
|
true => {
|
||||||
let s: String = Input::with_theme(&ColorfulTheme::default())
|
let name: String = match matches.value_of("name") {
|
||||||
.with_prompt("Category:")
|
Some(s) => s.to_string(),
|
||||||
.interact_text()?;
|
None => Input::with_theme(&ColorfulTheme::default())
|
||||||
notes::list_category(&s)?;
|
.with_prompt("Category:")
|
||||||
|
.interact_text()?,
|
||||||
|
};
|
||||||
|
notes::list_category(&name)?;
|
||||||
}
|
}
|
||||||
false => notes::list_all_notes()?,
|
false => notes::list_all_notes()?,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user