mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement
- Similar subcommands for 'uuids' as there is for 'ids' ('_uuids' and '_zshuuids'). - Extends the scope and the precision of the unit tests for ids. - Corresponding documentation in the man pages.
This commit is contained in:
parent
82a4607ec6
commit
fe954a6acc
7 changed files with 110 additions and 6 deletions
|
@ -22,6 +22,8 @@ Features
|
||||||
+ Filter optimization: with no 'OR' or 'XOR' operators, no UUIDS but with IDs
|
+ Filter optimization: with no 'OR' or 'XOR' operators, no UUIDS but with IDs
|
||||||
the completed.data file is not referenced
|
the completed.data file is not referenced
|
||||||
+ Reduced excessive number of sort columns on certain reports
|
+ Reduced excessive number of sort columns on certain reports
|
||||||
|
+ Similar helper subcommands for 'uuids' as for there is for 'ids' (_uuids and
|
||||||
|
_zshuuids).
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
+ Fixed bug #954, which caused bulk deletions when using a UUID filter term and
|
+ Fixed bug #954, which caused bulk deletions when using a UUID filter term and
|
||||||
|
|
|
@ -478,6 +478,10 @@ Lists all supported configuration variables, for completion purposes.
|
||||||
.B task <filter> _ids
|
.B task <filter> _ids
|
||||||
Shows only the IDs of matching tasks, in the form of a list.
|
Shows only the IDs of matching tasks, in the form of a list.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B task <filter> _uuids
|
||||||
|
Shows only the UUIDs of matching tasks, in the form of a list.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B task <filter> _projects
|
.B task <filter> _projects
|
||||||
Shows only a list of all project names used.
|
Shows only a list of all project names used.
|
||||||
|
@ -502,6 +506,10 @@ Generates a list of all commands, for zsh autocompletion purposes.
|
||||||
.B task <filter> _zshids
|
.B task <filter> _zshids
|
||||||
Shows the IDs and descriptions of matching tasks.
|
Shows the IDs and descriptions of matching tasks.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B task <filter> _zshuuids
|
||||||
|
Shows the UUIDs and descriptions of matching tasks.
|
||||||
|
|
||||||
.SH ATTRIBUTES AND METADATA
|
.SH ATTRIBUTES AND METADATA
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
|
|
|
@ -143,7 +143,7 @@ CmdUUIDs::CmdUUIDs ()
|
||||||
{
|
{
|
||||||
_keyword = "uuids";
|
_keyword = "uuids";
|
||||||
_usage = "task <filter> uuids";
|
_usage = "task <filter> uuids";
|
||||||
_description = STRING_CMD_UUIDS_USAGE;
|
_description = STRING_CMD_UUIDS_USAGE_RANGE;
|
||||||
_read_only = true;
|
_read_only = true;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
}
|
}
|
||||||
|
@ -168,3 +168,63 @@ int CmdUUIDs::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CmdCompletionUuids::CmdCompletionUuids ()
|
||||||
|
{
|
||||||
|
_keyword = "_uuids";
|
||||||
|
_usage = "task <filter> _uuids";
|
||||||
|
_description = STRING_CMD_UUIDS_USAGE_LIST;
|
||||||
|
_read_only = true;
|
||||||
|
_displays_id = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CmdCompletionUuids::execute (std::string& output)
|
||||||
|
{
|
||||||
|
// Apply filter.
|
||||||
|
handleRecurrence ();
|
||||||
|
std::vector <Task> filtered;
|
||||||
|
filter (filtered);
|
||||||
|
context.tdb2.commit ();
|
||||||
|
|
||||||
|
std::vector <std::string> uuids;
|
||||||
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
|
uuids.push_back (task->get ("uuid"));
|
||||||
|
|
||||||
|
join (output, "\n", uuids);
|
||||||
|
output += "\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CmdZshCompletionUuids::CmdZshCompletionUuids ()
|
||||||
|
{
|
||||||
|
_keyword = "_zshuuids";
|
||||||
|
_usage = "task <filter> _zshuuids";
|
||||||
|
_description = STRING_CMD_UUIDS_USAGE_ZSH;
|
||||||
|
_read_only = true;
|
||||||
|
_displays_id = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CmdZshCompletionUuids::execute (std::string& output)
|
||||||
|
{
|
||||||
|
// Apply filter.
|
||||||
|
handleRecurrence ();
|
||||||
|
std::vector <Task> filtered;
|
||||||
|
filter (filtered);
|
||||||
|
context.tdb2.commit ();
|
||||||
|
|
||||||
|
std::stringstream out;
|
||||||
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
|
out << task->get ("uuid")
|
||||||
|
<< ":"
|
||||||
|
<< task->get ("description")
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
|
output = out.str ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -60,5 +60,19 @@ public:
|
||||||
int execute (std::string&);
|
int execute (std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CmdCompletionUuids : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CmdCompletionUuids ();
|
||||||
|
int execute (std::string&);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CmdZshCompletionUuids : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CmdZshCompletionUuids ();
|
||||||
|
int execute (std::string&);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -114,6 +114,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||||
c = new CmdCompletionCommands (); all[c->keyword ()] = c;
|
c = new CmdCompletionCommands (); all[c->keyword ()] = c;
|
||||||
c = new CmdCompletionConfig (); all[c->keyword ()] = c;
|
c = new CmdCompletionConfig (); all[c->keyword ()] = c;
|
||||||
c = new CmdCompletionIds (); all[c->keyword ()] = c;
|
c = new CmdCompletionIds (); all[c->keyword ()] = c;
|
||||||
|
c = new CmdCompletionUuids (); all[c->keyword ()] = c;
|
||||||
c = new CmdCompletionProjects (); all[c->keyword ()] = c;
|
c = new CmdCompletionProjects (); all[c->keyword ()] = c;
|
||||||
c = new CmdCompletionTags (); all[c->keyword ()] = c;
|
c = new CmdCompletionTags (); all[c->keyword ()] = c;
|
||||||
c = new CmdCompletionVersion (); all[c->keyword ()] = c;
|
c = new CmdCompletionVersion (); all[c->keyword ()] = c;
|
||||||
|
@ -162,6 +163,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||||
c = new CmdVersion (); all[c->keyword ()] = c;
|
c = new CmdVersion (); all[c->keyword ()] = c;
|
||||||
c = new CmdZshCommands (); all[c->keyword ()] = c;
|
c = new CmdZshCommands (); all[c->keyword ()] = c;
|
||||||
c = new CmdZshCompletionIds (); all[c->keyword ()] = c;
|
c = new CmdZshCompletionIds (); all[c->keyword ()] = c;
|
||||||
|
c = new CmdZshCompletionUuids (); all[c->keyword ()] = c;
|
||||||
|
|
||||||
// Instantiate a command object for each custom report.
|
// Instantiate a command object for each custom report.
|
||||||
std::vector <std::string> variables;
|
std::vector <std::string> variables;
|
||||||
|
|
|
@ -220,7 +220,9 @@
|
||||||
#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 only 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 "Shows the UUIDs 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_LIST "Shows the UUIDs of matching tasks, as a list"
|
||||||
|
#define STRING_CMD_UUIDS_USAGE_ZSH "Shows the UUIDs and descriptions of matching tasks"
|
||||||
#define STRING_CMD_EXPORT_USAGE "Exports tasks in JSON format"
|
#define STRING_CMD_EXPORT_USAGE "Exports tasks in JSON format"
|
||||||
#define STRING_CMD_INFO_USAGE "Shows all data and metadata"
|
#define STRING_CMD_INFO_USAGE "Shows all data and metadata"
|
||||||
#define STRING_CMD_INFO_BLOCKED "This task blocked by"
|
#define STRING_CMD_INFO_BLOCKED "This task blocked by"
|
||||||
|
|
24
test/ids.t
24
test/ids.t
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More tests => 5;
|
use Test::More tests => 10;
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'ids.rc')
|
if (open my $fh, '>', 'ids.rc')
|
||||||
|
@ -47,13 +47,29 @@ qx{../src/task rc:ids.rc add four };
|
||||||
qx{../src/task rc:ids.rc add five +A +B};
|
qx{../src/task rc:ids.rc add five +A +B};
|
||||||
|
|
||||||
my $output = qx{../src/task rc:ids.rc ids +A};
|
my $output = qx{../src/task rc:ids.rc ids +A};
|
||||||
like ($output, qr/^1-3,5$/ms, 'ids +A --> 1-3,5');
|
like ($output, qr/^1-3,5$/, 'ids +A --> 1-3,5');
|
||||||
|
|
||||||
$output = qx{../src/task rc:ids.rc ids +B};
|
$output = qx{../src/task rc:ids.rc ids +B};
|
||||||
like ($output, qr/^1,3,5$/ms, 'ids +B --> 1,3,5');
|
like ($output, qr/^1,3,5$/, 'ids +B --> 1,3,5');
|
||||||
|
|
||||||
$output = qx{../src/task rc:ids.rc ids +A -B};
|
$output = qx{../src/task rc:ids.rc ids +A -B};
|
||||||
like ($output, qr/^2$/ms, 'ids +A -B --> 2');
|
like ($output, qr/^2$/, 'ids +A -B --> 2');
|
||||||
|
|
||||||
|
$output = qx{../src/task rc:ids.rc _ids +A};
|
||||||
|
like ($output, qr/^1\n2\n3\n5$/, '_ids +A --> 1\n2\n3\n5');
|
||||||
|
|
||||||
|
$output = qx{../src/task rc:ids.rc _zshids +A};
|
||||||
|
like ($output, qr/^1:one\n2:two\n3:three\n5:five$/, '_zshids +A --> 1:one\n2:two\n3:three\n5:five');
|
||||||
|
|
||||||
|
$output = qx{../src/task rc:ids.rc uuids +A};
|
||||||
|
like ($output, qr/^[0-9a-f-]+,[0-9a-f-]+,[0-9a-f-]+,[0-9a-f-]+$/, 'uuids +A --> uuid,uuid,uuid,uuid');
|
||||||
|
|
||||||
|
$output = qx{../src/task rc:ids.rc _uuids +A};
|
||||||
|
like ($output, qr/^[0-9a-f-]+\n[0-9a-f-]+\n[0-9a-f-]+\n[0-9a-f-]+$/, '_uuids +A --> uuid\nuuid\nuuid\nuuid');
|
||||||
|
|
||||||
|
# The order of the task may not be respected with _zshuuids
|
||||||
|
$output = qx{../src/task rc:ids.rc _zshuuids +A};
|
||||||
|
like ($output, qr/^[0-9a-f-]+:[a-z]+\n[0-9a-f-]+:[a-z]+\n[0-9a-f-]+:[a-z]+\n[0-9a-f-]+:[a-z]+$/, '_zshuuids +A --> uuid:*\nuuid:*\nuuid:*\nuuid:*');
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data synch.key ids.rc);
|
unlink qw(pending.data completed.data undo.data backlog.data synch.key ids.rc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue