Compare commits
No commits in common. "f0b79f0db0c6e089f64748412da60e20c122c306" and "65b3ddcc24bb91a9162ba0c543666771cd1d970f" have entirely different histories.
f0b79f0db0
...
65b3ddcc24
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>ru.kamask.pet</groupId>
|
<groupId>ru.kamask.pet</groupId>
|
||||||
<artifactId>todo</artifactId>
|
<artifactId>todo</artifactId>
|
||||||
<version>2.2.0-SNAPSHOT</version>
|
<version>2.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.release>24</maven.compiler.release>
|
<maven.compiler.release>24</maven.compiler.release>
|
||||||
|
|||||||
@ -28,19 +28,20 @@ public class ListCommand implements Command {
|
|||||||
return String.format(templateUsage, name(), "Список всех задач.");
|
return String.format(templateUsage, name(), "Список всех задач.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String formatWithTable(List<Task> tasks, String msgIfEmpty) {
|
String formatWithTable(List<Task> tasks, String msgIfEmpty){
|
||||||
String template = "%-2s | %-30s | %s\n";
|
String template = "%-2s | %-30s | %s\n";
|
||||||
var res = new StringBuilder(String.format(template, "ID", "Название задачи", "Статус"));
|
String res = "";
|
||||||
res.append("-".repeat(50) + "\n");
|
res += String.format(template, "ID", "Название задачи", "Статус");
|
||||||
|
res += "-".repeat(50) + "\n";
|
||||||
|
|
||||||
if (tasks.size() == 0)
|
if (tasks.size() == 0)
|
||||||
return res.append("\n" + msgIfEmpty).toString();
|
return res + "\n" + msgIfEmpty;
|
||||||
|
|
||||||
for (Task task : tasks) {
|
for (Task task : tasks) {
|
||||||
SimpleTask.Data data = ((SimpleTask) task).data();
|
SimpleTask.Data data = ((SimpleTask) task).data();
|
||||||
res.append(String.format(template, data.id(), data.title(), data.done() ? "выполнено" : "не выполнено"));
|
res += String.format(template, data.id(), data.title(), data.done() ? "выполнено" : "не выполнено");
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.toString();
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user