[TW-1938] Resolve conflicts between new-id and new-uuid

- new-uuid is *not* set by default
- new-uuid overrides new-id when set

The reasoning is that new-uuid is mostly used by code (eg: Python's
taskw module), whereas new-id is mostly used by humans.

By making new-uuid not set by default, calling code can set it to
receive UUIDs (preserving 2.5.x behaviour), but humans can continue to
use integer task IDs.
This commit is contained in:
Paul Fenwick 2017-12-04 11:27:22 -08:00
parent a54bcf685b
commit cc9e2a5076
2 changed files with 16 additions and 10 deletions

View file

@ -60,7 +60,21 @@ int CmdAdd::execute (std::string& output)
// Do not display ID 0, users cannot query by that
auto status = task.getStatus ();
if (context.verbose ("new-id") &&
// We may have a situation where both new-id and new-uuid config
// variables are set. In that case, we'll show the new-uuid, as
// it's enduring and never changes, and it's unlikely the caller
// asked for this if they just wanted a human-friendly number.
if (context.verbose ("new-uuid") &&
status != Task::recurring)
output += format (STRING_CMD_ADD_FEEDBACK, task.get ("uuid")) + '\n';
else if (context.verbose ("new-uuid") &&
status == Task::recurring)
output += format (STRING_CMD_ADD_RECUR, task.get ("uuid")) + '\n';
else if (context.verbose ("new-id") &&
(status == Task::pending ||
status == Task::waiting))
output += format (STRING_CMD_ADD_FEEDBACK, task.id) + '\n';
@ -69,14 +83,6 @@ int CmdAdd::execute (std::string& output)
status == Task::recurring)
output += format (STRING_CMD_ADD_RECUR, task.id) + '\n';
else if (context.verbose ("new-uuid") &&
status != Task::recurring)
output += format (STRING_CMD_ADD_FEEDBACK, task.get ("uuid")) + '\n';
else if (context.verbose ("new-uuid") &&
status == Task::recurring)
output += format (STRING_CMD_ADD_RECUR, task.get ("uuid")) + '\n';
if (context.verbose ("project"))
context.footnote (onProjectChange (task));