mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-09 09:40:37 +02:00
CmdPurge: Detect the failure mode of trying to purge non-deleted tasks
Prompted by the failure mode described by Glen Solsberry in #2254.
This commit is contained in:
parent
e37d932208
commit
d43fa66489
1 changed files with 7 additions and 0 deletions
|
@ -135,6 +135,7 @@ int CmdPurge::execute (std::string&)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
bool matched_deleted = false;
|
||||||
|
|
||||||
Filter filter;
|
Filter filter;
|
||||||
std::vector <Task> filtered;
|
std::vector <Task> filtered;
|
||||||
|
@ -156,6 +157,9 @@ int CmdPurge::execute (std::string&)
|
||||||
// mark tasks as deleted before purging.
|
// mark tasks as deleted before purging.
|
||||||
if (task.getStatus () == Task::deleted)
|
if (task.getStatus () == Task::deleted)
|
||||||
{
|
{
|
||||||
|
// Mark that at least one deleted task matched the filter
|
||||||
|
matched_deleted = true;
|
||||||
|
|
||||||
std::string question;
|
std::string question;
|
||||||
question = format ("Permanently remove task {1} '{2}'?",
|
question = format ("Permanently remove task {1} '{2}'?",
|
||||||
task.identifier (true),
|
task.identifier (true),
|
||||||
|
@ -166,6 +170,9 @@ int CmdPurge::execute (std::string&)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filtered.size () > 0 and ! matched_deleted)
|
||||||
|
Context::getContext ().footnote ("No deleted tasks specified. Maybe you forgot to delete tasks first?");
|
||||||
|
|
||||||
feedback_affected (count == 1 ? "Purged {1} task." : "Purged {1} tasks.", count);
|
feedback_affected (count == 1 ? "Purged {1} task." : "Purged {1} tasks.", count);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue