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("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.")
|
||||
|
@ -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())
|
||||
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(&s)?;
|
||||
.interact_text()?,
|
||||
};
|
||||
notes::list_category(&name)?;
|
||||
}
|
||||
false => notes::list_all_notes()?,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user