@@ -9,6 +9,7 @@ namespace cli = command_line_interpreter;
99// --- define commands ------
1010// --------------------------
1111#include " JsonGenerator.hpp"
12+ #include < serial_protocol/DeletedTaskObject.hpp>
1213#include < serial_protocol/ProtocolVersionObject.hpp>
1314#include < serial_protocol/TaskList.hpp>
1415#include < serial_protocol/TaskObject.hpp>
@@ -70,7 +71,19 @@ static const auto add = [](const TaskId id, const std::basic_string<ProtocolHand
7071};
7172static const auto addCmd = cli::makeCommand(" add" , std::function(add), std::make_tuple(&id, &label, &duration));
7273
73- static const std::array<const cli::BaseCommand<char > *, 4 > commands = {&listCmd, &editCmd, &infoCmd, &addCmd};
74+ // command for delete/remove
75+ static const auto del = [](const TaskId id) {
76+ const bool deleted = device::tasks.erase (id) > 0 ;
77+ const DeletedTaskObject taskObject{.id = id};
78+ serial_port::cout << toJsonString (taskObject) << std::endl;
79+ if (!deleted)
80+ {
81+ serial_port::cout << " ERROR: No task deleted." << std::endl;
82+ }
83+ };
84+ static const auto delCmd = cli::makeCommand(" delete" , std::function(del), std::make_tuple(&id));
85+
86+ static const std::array<const cli::BaseCommand<char > *, 5 > commands = {&listCmd, &editCmd, &infoCmd, &addCmd, &delCmd};
7487
7588bool ProtocolHandler::execute (const CharType *const commandLine)
7689{
0 commit comments