mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 19:17:19 +02:00
Commands - _urgency
- Migrated _urgency to CmdUrgency.
This commit is contained in:
parent
9af1c71daf
commit
bd93126f4e
8 changed files with 124 additions and 39 deletions
|
@ -134,7 +134,6 @@ void Cmd::load ()
|
||||||
commands.push_back ("_commands");
|
commands.push_back ("_commands");
|
||||||
commands.push_back ("_ids");
|
commands.push_back ("_ids");
|
||||||
commands.push_back ("_config");
|
commands.push_back ("_config");
|
||||||
commands.push_back ("_urgency");
|
|
||||||
commands.push_back ("_query");
|
commands.push_back ("_query");
|
||||||
commands.push_back ("_zshcommands");
|
commands.push_back ("_zshcommands");
|
||||||
commands.push_back ("_zshids");
|
commands.push_back ("_zshids");
|
||||||
|
@ -236,7 +235,6 @@ bool Cmd::isReadOnlyCommand ()
|
||||||
command == "_commands" ||
|
command == "_commands" ||
|
||||||
command == "_ids" ||
|
command == "_ids" ||
|
||||||
command == "_config" ||
|
command == "_config" ||
|
||||||
command == "_urgency" ||
|
|
||||||
command == "_query" ||
|
command == "_query" ||
|
||||||
command == "_zshcommands" ||
|
command == "_zshcommands" ||
|
||||||
command == "_zshids" ||
|
command == "_zshids" ||
|
||||||
|
|
|
@ -289,7 +289,6 @@ int Context::dispatch (std::string &out)
|
||||||
else if (cmd.command == "_commands") { rc = handleCompletionCommands (out); }
|
else if (cmd.command == "_commands") { rc = handleCompletionCommands (out); }
|
||||||
else if (cmd.command == "_ids") { rc = handleCompletionIDs (out); }
|
else if (cmd.command == "_ids") { rc = handleCompletionIDs (out); }
|
||||||
else if (cmd.command == "_config") { rc = handleCompletionConfig (out); }
|
else if (cmd.command == "_config") { rc = handleCompletionConfig (out); }
|
||||||
else if (cmd.command == "_urgency") { rc = handleUrgency (out); }
|
|
||||||
else if (cmd.command == "_query") { rc = handleQuery (out); }
|
else if (cmd.command == "_query") { rc = handleQuery (out); }
|
||||||
else if (cmd.command == "_zshcommands") { rc = handleZshCompletionCommands (out); }
|
else if (cmd.command == "_zshcommands") { rc = handleZshCompletionCommands (out); }
|
||||||
else if (cmd.command == "_zshids") { rc = handleZshCompletionIDs (out); }
|
else if (cmd.command == "_zshids") { rc = handleZshCompletionIDs (out); }
|
||||||
|
|
|
@ -411,41 +411,6 @@ int handleCompletionConfig (std::string& outs)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Temporary command to display urgency for a task.
|
|
||||||
int handleUrgency (std::string& outs)
|
|
||||||
{
|
|
||||||
// Get all the tasks.
|
|
||||||
std::vector <Task> tasks;
|
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
|
||||||
handleRecurrence ();
|
|
||||||
context.tdb.loadPending (tasks, context.filter);
|
|
||||||
context.tdb.commit ();
|
|
||||||
context.tdb.unlock ();
|
|
||||||
|
|
||||||
// Filter sequence.
|
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
|
||||||
if (tasks.size () == 0)
|
|
||||||
{
|
|
||||||
std::cout << "No tasks specified.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the task(s).
|
|
||||||
std::stringstream out;
|
|
||||||
foreach (task, tasks)
|
|
||||||
{
|
|
||||||
out << "task "
|
|
||||||
<< task->id
|
|
||||||
<< " urgency "
|
|
||||||
<< task->urgency ()
|
|
||||||
<< "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
outs = out.str ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int handleQuery (std::string& outs)
|
int handleQuery (std::string& outs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@ set (commands_SRCS Command.cpp Command.h
|
||||||
CmdShow.cpp CmdShow.h
|
CmdShow.cpp CmdShow.h
|
||||||
CmdTags.cpp CmdTags.h
|
CmdTags.cpp CmdTags.h
|
||||||
CmdTip.cpp CmdTip.h
|
CmdTip.cpp CmdTip.h
|
||||||
|
CmdUrgency.cpp CmdUrgency.h
|
||||||
CmdVersion.cpp CmdVersion.h)
|
CmdVersion.cpp CmdVersion.h)
|
||||||
|
|
||||||
add_library (commands STATIC ${commands_SRCS})
|
add_library (commands STATIC ${commands_SRCS})
|
||||||
|
|
79
src/commands/CmdUrgency.cpp
Normal file
79
src/commands/CmdUrgency.cpp
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// taskwarrior - a command line task list manager.
|
||||||
|
//
|
||||||
|
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License as published by the Free Software
|
||||||
|
// Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
// version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
// details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along with
|
||||||
|
// this program; if not, write to the
|
||||||
|
//
|
||||||
|
// Free Software Foundation, Inc.,
|
||||||
|
// 51 Franklin Street, Fifth Floor,
|
||||||
|
// Boston, MA
|
||||||
|
// 02110-1301
|
||||||
|
// USA
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <Context.h>
|
||||||
|
#include <main.h>
|
||||||
|
#include <CmdUrgency.h>
|
||||||
|
|
||||||
|
extern Context context;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CmdUrgency::CmdUrgency ()
|
||||||
|
{
|
||||||
|
_keyword = "_urgency";
|
||||||
|
_usage = "task _urgency <IDs>";
|
||||||
|
_description = "Displays the urgency measure of a task.";
|
||||||
|
_read_only = true;
|
||||||
|
_displays_id = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CmdUrgency::execute (const std::string& command_line, std::string& output)
|
||||||
|
{
|
||||||
|
// Get all the tasks.
|
||||||
|
std::vector <Task> tasks;
|
||||||
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
|
handleRecurrence ();
|
||||||
|
context.tdb.loadPending (tasks, context.filter);
|
||||||
|
context.tdb.commit ();
|
||||||
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
// Filter sequence.
|
||||||
|
context.filter.applySequence (tasks, context.sequence);
|
||||||
|
if (tasks.size () == 0)
|
||||||
|
{
|
||||||
|
context.footnote ("No tasks specified.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the task(s).
|
||||||
|
std::stringstream out;
|
||||||
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
|
out << "task "
|
||||||
|
<< task->id
|
||||||
|
<< " urgency "
|
||||||
|
<< task->urgency ()
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
|
output = out.str ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
42
src/commands/CmdUrgency.h
Normal file
42
src/commands/CmdUrgency.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// taskwarrior - a command line task list manager.
|
||||||
|
//
|
||||||
|
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License as published by the Free Software
|
||||||
|
// Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
// version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
// details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along with
|
||||||
|
// this program; if not, write to the
|
||||||
|
//
|
||||||
|
// Free Software Foundation, Inc.,
|
||||||
|
// 51 Franklin Street, Fifth Floor,
|
||||||
|
// Boston, MA
|
||||||
|
// 02110-1301
|
||||||
|
// USA
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef INCLUDED_CMDURGENCY
|
||||||
|
#define INCLUDED_CMDURGENCY
|
||||||
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <Command.h>
|
||||||
|
|
||||||
|
class CmdUrgency : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CmdUrgency ();
|
||||||
|
int execute (const std::string&, std::string&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
|
@ -39,6 +39,7 @@
|
||||||
#include <CmdShow.h>
|
#include <CmdShow.h>
|
||||||
#include <CmdTags.h>
|
#include <CmdTags.h>
|
||||||
#include <CmdTip.h>
|
#include <CmdTip.h>
|
||||||
|
#include <CmdUrgency.h>
|
||||||
#include <CmdVersion.h>
|
#include <CmdVersion.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||||
c = new CmdShow (); all[c->keyword ()] = c;
|
c = new CmdShow (); all[c->keyword ()] = c;
|
||||||
c = new CmdTags (); all[c->keyword ()] = c;
|
c = new CmdTags (); all[c->keyword ()] = c;
|
||||||
c = new CmdTip (); all[c->keyword ()] = c;
|
c = new CmdTip (); all[c->keyword ()] = c;
|
||||||
|
c = new CmdUrgency (); all[c->keyword ()] = c;
|
||||||
c = new CmdVersion (); all[c->keyword ()] = c;
|
c = new CmdVersion (); all[c->keyword ()] = c;
|
||||||
|
|
||||||
// Instantiate a command object for each custom report.
|
// Instantiate a command object for each custom report.
|
||||||
|
|
|
@ -62,7 +62,6 @@ int handleCompletionTags (std::string&);
|
||||||
int handleCompletionCommands (std::string&);
|
int handleCompletionCommands (std::string&);
|
||||||
int handleCompletionIDs (std::string&);
|
int handleCompletionIDs (std::string&);
|
||||||
int handleCompletionConfig (std::string&);
|
int handleCompletionConfig (std::string&);
|
||||||
int handleUrgency (std::string&);
|
|
||||||
int handleQuery (std::string&);
|
int handleQuery (std::string&);
|
||||||
int handleZshCompletionCommands (std::string&);
|
int handleZshCompletionCommands (std::string&);
|
||||||
int handleZshCompletionIDs (std::string&);
|
int handleZshCompletionIDs (std::string&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue