mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
TW-1704: Task: Use Task::identifier to reference the task
To achieve consistent output, use a helper method to generate a proper handle - ID for tasks with non-zero ID, UUID otherwise.
This commit is contained in:
parent
1236abc7d5
commit
2d25cf6f59
16 changed files with 50 additions and 57 deletions
14
src/Task.cpp
14
src/Task.cpp
|
@ -202,6 +202,20 @@ std::string Task::statusToText (Task::status s)
|
|||
return "pending";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Returns a proper handle to the task. Tasks should not be referenced by UUIDs
|
||||
// as long as they have non-zero ID.
|
||||
//
|
||||
const std::string Task::identifier (bool shortened /* = false */) const
|
||||
{
|
||||
if (this->id != 0)
|
||||
return format (this->id);
|
||||
else if (shortened)
|
||||
return this->get ("uuid").substr (0, 8);
|
||||
else
|
||||
return this->get ("uuid");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::setAsNow (const std::string& att)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue