Code Cleanup

- Simpler code for 'ids' command.
- Sort the uuids with 'uuids' and '_uuids' commands (stabler output).
This commit is contained in:
Louis-Claude Canon 2012-05-22 17:03:35 +02:00 committed by Paul Beckingham
parent 0b1b677aa5
commit 988288f6d2
2 changed files with 5 additions and 7 deletions

View file

@ -96,12 +96,8 @@ int CmdCompletionIds::execute (std::string& output)
ids.push_back (task->id); ids.push_back (task->id);
std::sort (ids.begin (), ids.end ()); std::sort (ids.begin (), ids.end ());
std::stringstream out; join (output, "\n", ids);
std::vector <int>::iterator id; output += "\n";
for (id = ids.begin (); id != ids.end (); ++id)
out << *id << "\n";
output = out.str ();
return 0; return 0;
} }
@ -162,6 +158,7 @@ int CmdUUIDs::execute (std::string& output)
for (task = filtered.begin (); task != filtered.end (); ++task) for (task = filtered.begin (); task != filtered.end (); ++task)
uuids.push_back (task->get ("uuid")); uuids.push_back (task->get ("uuid"));
std::sort (uuids.begin (), uuids.end ());
join (output, ",", uuids); join (output, ",", uuids);
output += "\n"; output += "\n";
return 0; return 0;
@ -191,6 +188,7 @@ int CmdCompletionUuids::execute (std::string& output)
for (task = filtered.begin (); task != filtered.end (); ++task) for (task = filtered.begin (); task != filtered.end (); ++task)
uuids.push_back (task->get ("uuid")); uuids.push_back (task->get ("uuid"));
std::sort (uuids.begin (), uuids.end ());
join (output, "\n", uuids); join (output, "\n", uuids);
output += "\n"; output += "\n";
return 0; return 0;

View file

@ -218,7 +218,7 @@
#define STRING_CMD_LOG_NO_WAITING "You cannot log waiting tasks." #define STRING_CMD_LOG_NO_WAITING "You cannot log waiting tasks."
#define STRING_CMD_LOG_LOGGED "Logged task." #define STRING_CMD_LOG_LOGGED "Logged task."
#define STRING_CMD_IDS_USAGE_RANGE "Shows the IDs of matching tasks, as a range" #define STRING_CMD_IDS_USAGE_RANGE "Shows the IDs of matching tasks, as a range"
#define STRING_CMD_IDS_USAGE_LIST "Shows only the IDs of matching tasks, in the form of a list" #define STRING_CMD_IDS_USAGE_LIST "Shows the IDs of matching tasks, in the form of a list"
#define STRING_CMD_IDS_USAGE_ZSH "Shows the IDs and descriptions of matching tasks" #define STRING_CMD_IDS_USAGE_ZSH "Shows the IDs and descriptions of matching tasks"
#define STRING_CMD_UUIDS_USAGE_RANGE "Shows the UUIDs of matching tasks, as a comma-separated list" #define STRING_CMD_UUIDS_USAGE_RANGE "Shows the UUIDs of matching tasks, as a comma-separated list"
#define STRING_CMD_UUIDS_USAGE_LIST "Shows the UUIDs of matching tasks, as a list" #define STRING_CMD_UUIDS_USAGE_LIST "Shows the UUIDs of matching tasks, as a list"