From a52071258afa333a89988da3ee7297603f507657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Mon, 18 Jul 2022 15:44:37 +0200 Subject: [PATCH] Format list. --- src/habitmgr.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/habitmgr.rs b/src/habitmgr.rs index 3833d33..989ea34 100644 --- a/src/habitmgr.rs +++ b/src/habitmgr.rs @@ -108,12 +108,25 @@ impl HabitMgr println!("Removed habit {}", old_habit.get_name()); } - pub fn list(&mut self, all:bool, verbose:bool) + pub fn list(&mut self, _all:bool, _verbose:bool) { self.import_habits(); - for (i, habit) in self.habits.iter().enumerate() + if self.habits.is_empty() { - println!("{}\t{}", i, habit.get_name()); + println!("There are no habits. Add one!"); + } + else + { + println!(" {0: <3} | {1: <5} | {2: <6} | {3}", + "id", "bad", "weight", "name"); + for (i, habit) in self.habits.iter().enumerate() + { + println!(" {0: <3} | {1: <5} | {2: <6} | {3}", + i, + habit.get_bad(), + habit.get_weight(), + habit.get_name()); + } } } }