From cc9e2a50766db14ffee60fe8a2bc089ac7f6d587 Mon Sep 17 00:00:00 2001 From: Paul Fenwick Date: Mon, 4 Dec 2017 11:27:22 -0800 Subject: [PATCH] [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. --- src/Context.cpp | 2 +- src/commands/CmdAdd.cpp | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index e40bd44c0..a29d82482 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -88,7 +88,7 @@ std::string configurationDefaults = "\n" "# Miscellaneous\n" "# # Comma-separated list. May contain any subset of:\n" - "verbose=blank,header,footnote,label,new-id,new-uuid,affected,edit,special,project,sync,unwait,override,recur\n" + "verbose=blank,header,footnote,label,new-id,affected,edit,special,project,sync,unwait,override,recur\n" "confirmation=1 # Confirmation on delete, big changes\n" "recurrence=1 # Enable recurrence\n" "recurrence.confirmation=prompt # Confirmation for propagating changes among recurring tasks (yes/no/prompt)\n" diff --git a/src/commands/CmdAdd.cpp b/src/commands/CmdAdd.cpp index 6993c91c3..9d08287b6 100644 --- a/src/commands/CmdAdd.cpp +++ b/src/commands/CmdAdd.cpp @@ -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));