Skip to content

Commit

Permalink
add list-title subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Sep 6, 2020
1 parent b412fe3 commit f09066e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/command/list_title.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pub fn list_title(all: bool) -> Result<(), Box<dyn std::error::Error>> {
let titles = crate::use_case::list_title::list_title(all)?;
for title in titles {
println!(
"{}\t{}",
title.title.to_string(),
if title.obsoleted { "(obsoleted)" } else { "" }
);
}
Ok(())
}
1 change: 1 addition & 0 deletions src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod edit;
pub mod list;
pub mod list_title;
pub mod new;
pub mod server;
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.help("Prints obsoleted memos"),
),
)
.subcommand(
clap::SubCommand::with_name("list-title")
.about("Lists memo titles")
.arg(
clap::Arg::with_name("obsoleted")
.long("obsoleted")
.help("Prints obsoleted memo titles"),
),
)
.subcommand(clap::SubCommand::with_name("new").about("Creates a new memo"))
.subcommand(clap::SubCommand::with_name("server").about("Runs server"))
.get_matches();
Expand All @@ -41,6 +50,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let obsoleted = sub_matches.is_present("obsoleted");
crate::command::list::list(obsoleted)?
}
("list-title", Some(sub_matches)) => {
let obsoleted = sub_matches.is_present("obsoleted");
crate::command::list_title::list_title(obsoleted)?
}
("server", _) => crate::command::server::server()?,
_ => {}
}
Expand Down

0 comments on commit f09066e

Please sign in to comment.