Format list.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-07-18 15:44:37 +02:00
parent d7f38f26b9
commit a52071258a

View File

@ -108,12 +108,25 @@ impl HabitMgr
println!("Removed habit {}", old_habit.get_name()); 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(); self.import_habits();
if self.habits.is_empty()
{
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() for (i, habit) in self.habits.iter().enumerate()
{ {
println!("{}\t{}", i, habit.get_name()); println!(" {0: <3} | {1: <5} | {2: <6} | {3}",
i,
habit.get_bad(),
habit.get_weight(),
habit.get_name());
}
} }
} }
} }