Skip to content

Commit

Permalink
Merge pull request #22 from jfding/new_cmd_listall
Browse files Browse the repository at this point in the history
new cmd listall to list all tasks
  • Loading branch information
jfding committed Sep 18, 2024
2 parents 6e9b7a9 + b71c725 commit 1e299df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ pub enum Commands {
#[clap(visible_alias("m"))]
Mark,

/// -> list all todo items in inbox
/// -> list all uncompeleted tasks in box
#[clap(visible_aliases(["l", "ls"]))]
List {
#[arg(short, long)]
all: bool,
},
List,

/// -> list all(including compeleted) tasks
#[clap(visible_aliases(["la"]))]
Listall,

/// -> list all todo box in working dir
#[clap(visible_aliases(["lb"]))]
Expand Down
16 changes: 10 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ fn main() {
let inbox_path = get_inbox_file(args.dir, inbox);

match args.command {
Some(Commands::Mark) | None => {
Some(Commands::List) | None => {
let mut todo = TaskBox::new(inbox_path);
todo.list(false);
}
Some(Commands::Listall) => {
let mut todo = TaskBox::new(inbox_path);
todo.list(true);
}

Some(Commands::Mark) => {
let mut todo = TaskBox::new(inbox_path);
let (tasks,_) = todo._get_all();
if tasks.is_empty() {
Expand Down Expand Up @@ -51,11 +60,6 @@ fn main() {
execute!(io::stdout(), DefaultUserShape).expect("failed to set cursor");
}

Some(Commands::List { all }) => {
let mut todo = TaskBox::new(inbox_path);
todo.list(all);
}

Some(Commands::Add { what, date }) => {
let mut todo = TaskBox::new(inbox_path);

Expand Down

0 comments on commit 1e299df

Please sign in to comment.