mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Command - undo
- Migrated handleUndo to CmdUndo.
This commit is contained in:
parent
4c47748dd7
commit
2fb743992f
9 changed files with 100 additions and 19 deletions
|
@ -132,7 +132,6 @@ void Cmd::load ()
|
||||||
commands.push_back ("delete");
|
commands.push_back ("delete");
|
||||||
commands.push_back ("done");
|
commands.push_back ("done");
|
||||||
commands.push_back ("timesheet");
|
commands.push_back ("timesheet");
|
||||||
commands.push_back ("undo");
|
|
||||||
commands.push_back ("merge");
|
commands.push_back ("merge");
|
||||||
commands.push_back ("push");
|
commands.push_back ("push");
|
||||||
commands.push_back ("pull");
|
commands.push_back ("pull");
|
||||||
|
@ -207,8 +206,7 @@ bool Cmd::isWriteCommand ()
|
||||||
if (command == "merge" ||
|
if (command == "merge" ||
|
||||||
command == "delete" ||
|
command == "delete" ||
|
||||||
command == "done" ||
|
command == "done" ||
|
||||||
command == "pull" ||
|
command == "pull")
|
||||||
command == "undo")
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -252,7 +252,6 @@ int Context::dispatch (std::string &out)
|
||||||
if (cmd.command == "timesheet") { rc = handleReportTimesheet (out); }
|
if (cmd.command == "timesheet") { rc = handleReportTimesheet (out); }
|
||||||
else if (cmd.command == "done") { rc = handleDone (out); }
|
else if (cmd.command == "done") { rc = handleDone (out); }
|
||||||
else if (cmd.command == "delete") { rc = handleDelete (out); }
|
else if (cmd.command == "delete") { rc = handleDelete (out); }
|
||||||
else if (cmd.command == "undo") { handleUndo ( ); }
|
|
||||||
else if (cmd.command == "merge") { tdb.gc ();
|
else if (cmd.command == "merge") { tdb.gc ();
|
||||||
handleMerge (out); }
|
handleMerge (out); }
|
||||||
else if (cmd.command == "push") { handlePush (out); }
|
else if (cmd.command == "push") { handlePush (out); }
|
||||||
|
|
|
@ -51,16 +51,6 @@
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void handleUndo ()
|
|
||||||
{
|
|
||||||
context.disallowModification ();
|
|
||||||
|
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
|
||||||
context.tdb.undo ();
|
|
||||||
context.tdb.unlock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void handleMerge (std::string&)
|
void handleMerge (std::string&)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,7 @@ set (commands_SRCS Command.cpp Command.h
|
||||||
CmdSummary.cpp CmdSummary.h
|
CmdSummary.cpp CmdSummary.h
|
||||||
CmdTags.cpp CmdTags.h
|
CmdTags.cpp CmdTags.h
|
||||||
CmdTip.cpp CmdTip.h
|
CmdTip.cpp CmdTip.h
|
||||||
|
CmdUndo.cpp CmdUndo.h
|
||||||
CmdUrgency.cpp CmdUrgency.h
|
CmdUrgency.cpp CmdUrgency.h
|
||||||
CmdVersion.cpp CmdVersion.h)
|
CmdVersion.cpp CmdVersion.h)
|
||||||
|
|
||||||
|
|
|
@ -103,10 +103,6 @@ int CmdHelp::execute (const std::string&, std::string& output)
|
||||||
view.set (row, 1, "task ID");
|
view.set (row, 1, "task ID");
|
||||||
view.set (row, 2, "Specifying an ID without a command invokes the 'info' command.");
|
view.set (row, 2, "Specifying an ID without a command invokes the 'info' command.");
|
||||||
|
|
||||||
row = view.addRow ();
|
|
||||||
view.set (row, 1, "task undo");
|
|
||||||
view.set (row, 2, "Reverts the most recent action.");
|
|
||||||
|
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 1, "task delete ID");
|
view.set (row, 1, "task delete ID");
|
||||||
view.set (row, 2, "Deletes the specified task.");
|
view.set (row, 2, "Deletes the specified task.");
|
||||||
|
|
54
src/commands/CmdUndo.cpp
Normal file
54
src/commands/CmdUndo.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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 <Context.h>
|
||||||
|
#include <CmdUndo.h>
|
||||||
|
|
||||||
|
extern Context context;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CmdUndo::CmdUndo ()
|
||||||
|
{
|
||||||
|
_keyword = "undo";
|
||||||
|
_usage = "task undo";
|
||||||
|
_description = "Reverts the most recent change to a task.";
|
||||||
|
_read_only = false;
|
||||||
|
_displays_id = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CmdUndo::execute (const std::string&, std::string& output)
|
||||||
|
{
|
||||||
|
context.disallowModification ();
|
||||||
|
|
||||||
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
|
context.tdb.undo ();
|
||||||
|
context.tdb.unlock ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
42
src/commands/CmdUndo.h
Normal file
42
src/commands/CmdUndo.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_CMDUNDO
|
||||||
|
#define INCLUDED_CMDUNDO
|
||||||
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <Command.h>
|
||||||
|
|
||||||
|
class CmdUndo : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CmdUndo ();
|
||||||
|
int execute (const std::string&, std::string&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
|
@ -63,6 +63,7 @@
|
||||||
#include <CmdSummary.h>
|
#include <CmdSummary.h>
|
||||||
#include <CmdTags.h>
|
#include <CmdTags.h>
|
||||||
#include <CmdTip.h>
|
#include <CmdTip.h>
|
||||||
|
#include <CmdUndo.h>
|
||||||
#include <CmdUrgency.h>
|
#include <CmdUrgency.h>
|
||||||
#include <CmdVersion.h>
|
#include <CmdVersion.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
@ -118,6 +119,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||||
c = new CmdSummary (); all[c->keyword ()] = c;
|
c = new CmdSummary (); 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 CmdUndo (); all[c->keyword ()] = c;
|
||||||
c = new CmdUrgency (); 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;
|
||||||
c = new CmdZshCommands (); all[c->keyword ()] = c;
|
c = new CmdZshCommands (); all[c->keyword ()] = c;
|
||||||
|
|
|
@ -53,7 +53,6 @@ bool nag (Task&);
|
||||||
int handleDone (std::string&);
|
int handleDone (std::string&);
|
||||||
int handleModify (std::string&);
|
int handleModify (std::string&);
|
||||||
int handleDelete (std::string&);
|
int handleDelete (std::string&);
|
||||||
void handleUndo ();
|
|
||||||
void handleMerge (std::string&);
|
void handleMerge (std::string&);
|
||||||
void handlePush (std::string&);
|
void handlePush (std::string&);
|
||||||
void handlePull (std::string&);
|
void handlePull (std::string&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue