From 109dbdabbb30a5af506258aa84719c4114ef59bd Mon Sep 17 00:00:00 2001 From: Madeleine Date: Sat, 25 Feb 2023 00:22:23 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20is=5Fsome()=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli/cmds.rs | 18 ++++++++---------- src/tasks.rs | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/cli/cmds.rs b/src/cli/cmds.rs index 176252e..84d54a5 100644 --- a/src/cli/cmds.rs +++ b/src/cli/cmds.rs @@ -14,16 +14,6 @@ fn parse_tags(tags: Option) -> Option> { pub fn show(tasks: &mut Tasks, id: Option) -> Result<(), TasksError> { // If no id is given, print out all tasks if let Some(..) = id { - if tasks.is_empty() { - // Output when no tasks are available - output::info(String::from("no tasks found")) - } else { - // Generate the table of all tasks - let table = tables::tasks_table(tasks); - // Print the table - println!("{}", table); - }; - } else { // Get the task the user wants to see let id = id.unwrap(); let task = tasks.get_task(id)?; @@ -32,6 +22,14 @@ pub fn show(tasks: &mut Tasks, id: Option) -> Result<(), TasksError> { let table = tables::task_table(task, id); // Print the table println!("{}", table); + } else if tasks.is_empty() { + // Output when no tasks are available + output::info(String::from("no tasks found")) + } else { + // Generate the table of all tasks + let table = tables::tasks_table(tasks); + // Print the table + println!("{}", table); }; // Success diff --git a/src/tasks.rs b/src/tasks.rs index ef45c59..8508b78 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -103,7 +103,7 @@ impl Task { } pub fn stop(&mut self) { - if self.when.is_none() { + if self.when.is_some() { self.status = Status::Inbox; } else { self.status = Status::Pending;