Commands - edit
- Migrated edit.cpp to CmdEdit.
This commit is contained in:
@@ -43,7 +43,6 @@ set (task_SRCS API.cpp API.h
|
|||||||
burndown.cpp
|
burndown.cpp
|
||||||
command.cpp
|
command.cpp
|
||||||
dependency.cpp
|
dependency.cpp
|
||||||
edit.cpp
|
|
||||||
export.cpp
|
export.cpp
|
||||||
feedback.cpp
|
feedback.cpp
|
||||||
history.cpp
|
history.cpp
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ void Cmd::load ()
|
|||||||
commands.push_back ("delete");
|
commands.push_back ("delete");
|
||||||
commands.push_back ("done");
|
commands.push_back ("done");
|
||||||
commands.push_back ("duplicate");
|
commands.push_back ("duplicate");
|
||||||
commands.push_back ("edit");
|
|
||||||
commands.push_back ("help");
|
commands.push_back ("help");
|
||||||
commands.push_back ("import");
|
commands.push_back ("import");
|
||||||
commands.push_back ("log");
|
commands.push_back ("log");
|
||||||
@@ -281,7 +280,6 @@ bool Cmd::isWriteCommand ()
|
|||||||
command == "delete" ||
|
command == "delete" ||
|
||||||
command == "done" ||
|
command == "done" ||
|
||||||
command == "duplicate" ||
|
command == "duplicate" ||
|
||||||
command == "edit" ||
|
|
||||||
command == "import" ||
|
command == "import" ||
|
||||||
command == "log" ||
|
command == "log" ||
|
||||||
command == "prepend" ||
|
command == "prepend" ||
|
||||||
|
|||||||
@@ -276,7 +276,6 @@ int Context::dispatch (std::string &out)
|
|||||||
else if (cmd.command == "export.yaml") { rc = handleExportYAML (out); }
|
else if (cmd.command == "export.yaml") { rc = handleExportYAML (out); }
|
||||||
else if (cmd.command == "import") { rc = handleImport (out); }
|
else if (cmd.command == "import") { rc = handleImport (out); }
|
||||||
else if (cmd.command == "duplicate") { rc = handleDuplicate (out); }
|
else if (cmd.command == "duplicate") { rc = handleDuplicate (out); }
|
||||||
else if (cmd.command == "edit") { rc = handleEdit (out); }
|
|
||||||
else if (cmd.command == "shell") { handleShell ( ); }
|
else if (cmd.command == "shell") { handleShell ( ); }
|
||||||
else if (cmd.command == "undo") { handleUndo ( ); }
|
else if (cmd.command == "undo") { handleUndo ( ); }
|
||||||
else if (cmd.command == "merge") { tdb.gc ();
|
else if (cmd.command == "merge") { tdb.gc ();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||||||
set (commands_SRCS Command.cpp Command.h
|
set (commands_SRCS Command.cpp Command.h
|
||||||
CmdCustom.cpp CmdCustom.h
|
CmdCustom.cpp CmdCustom.h
|
||||||
CmdDiagnostics.cpp CmdDiagnostics.h
|
CmdDiagnostics.cpp CmdDiagnostics.h
|
||||||
|
CmdEdit.cpp CmdEdit.h
|
||||||
CmdExec.cpp CmdExec.h
|
CmdExec.cpp CmdExec.h
|
||||||
CmdHelp.cpp CmdHelp.h
|
CmdHelp.cpp CmdHelp.h
|
||||||
CmdInfo.cpp CmdInfo.h
|
CmdInfo.cpp CmdInfo.h
|
||||||
|
|||||||
@@ -24,27 +24,63 @@
|
|||||||
// USA
|
// USA
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include <Date.h>
|
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
|
#include <Context.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
#include <CmdEdit.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static std::string findValue (
|
CmdEdit::CmdEdit ()
|
||||||
|
{
|
||||||
|
_keyword = "edit";
|
||||||
|
_usage = "task edit <ID>";
|
||||||
|
_description = "Launches an editor to let you modify all aspects of a task "
|
||||||
|
"directly, therefore it is to be used carefully.";
|
||||||
|
_read_only = false;
|
||||||
|
_displays_id = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Introducing the Silver Bullet. This feature is the catch-all fixative for
|
||||||
|
// various other ills. This is like opening up the hood and going in with a
|
||||||
|
// wrench. To be used sparingly.
|
||||||
|
int CmdEdit::execute (const std::string& command_line, std::string& output)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
std::stringstream out;
|
||||||
|
|
||||||
|
std::vector <Task> tasks;
|
||||||
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
|
handleRecurrence ();
|
||||||
|
Filter filter;
|
||||||
|
context.tdb.loadPending (tasks, filter);
|
||||||
|
|
||||||
|
// Filter sequence.
|
||||||
|
std::vector <Task> all = tasks;
|
||||||
|
context.filter.applySequence (tasks, context.sequence);
|
||||||
|
|
||||||
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
|
if (editFile (*task))
|
||||||
|
context.tdb.update (*task);
|
||||||
|
|
||||||
|
context.tdb.commit ();
|
||||||
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
output = out.str ();
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string CmdEdit::findValue (
|
||||||
const std::string& text,
|
const std::string& text,
|
||||||
const std::string& name)
|
const std::string& name)
|
||||||
{
|
{
|
||||||
@@ -66,7 +102,7 @@ static std::string findValue (
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static std::string findDate (
|
std::string CmdEdit::findDate (
|
||||||
const std::string& text,
|
const std::string& text,
|
||||||
const std::string& name)
|
const std::string& name)
|
||||||
{
|
{
|
||||||
@@ -92,7 +128,7 @@ static std::string findDate (
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static std::string formatDate (
|
std::string CmdEdit::formatDate (
|
||||||
Task& task,
|
Task& task,
|
||||||
const std::string& attribute)
|
const std::string& attribute)
|
||||||
{
|
{
|
||||||
@@ -107,7 +143,7 @@ static std::string formatDate (
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static std::string formatTask (Task task)
|
std::string CmdEdit::formatTask (Task task)
|
||||||
{
|
{
|
||||||
std::stringstream before;
|
std::stringstream before;
|
||||||
bool verbose = context.config.getBoolean ("edit.verbose");
|
bool verbose = context.config.getBoolean ("edit.verbose");
|
||||||
@@ -194,7 +230,7 @@ static std::string formatTask (Task task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static void parseTask (Task& task, const std::string& after)
|
void CmdEdit::parseTask (Task& task, const std::string& after)
|
||||||
{
|
{
|
||||||
// project
|
// project
|
||||||
std::string value = findValue (after, "\n Project:");
|
std::string value = findValue (after, "\n Project:");
|
||||||
@@ -202,12 +238,12 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (value != "")
|
if (value != "")
|
||||||
{
|
{
|
||||||
std::cout << "Project modified.\n";
|
context.footnote ("Project modified.");
|
||||||
task.set ("project", value);
|
task.set ("project", value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Project deleted.\n";
|
context.footnote ("Project deleted.");
|
||||||
task.remove ("project");
|
task.remove ("project");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,13 +256,13 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (Att::validNameValue ("priority", "", value))
|
if (Att::validNameValue ("priority", "", value))
|
||||||
{
|
{
|
||||||
std::cout << "Priority modified.\n";
|
context.footnote ("Priority modified.");
|
||||||
task.set ("priority", value);
|
task.set ("priority", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Priority deleted.\n";
|
context.footnote ("Priority deleted.");
|
||||||
task.remove ("priority");
|
task.remove ("priority");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,7 +280,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (value != "")
|
if (value != "")
|
||||||
{
|
{
|
||||||
std::cout << "Description modified.\n";
|
context.footnote ("Description modified.");
|
||||||
task.set ("description", value);
|
task.set ("description", value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -260,7 +296,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
Date original (::atoi (task.get ("entry").c_str ()));
|
Date original (::atoi (task.get ("entry").c_str ()));
|
||||||
if (!original.sameDay (edited))
|
if (!original.sameDay (edited))
|
||||||
{
|
{
|
||||||
std::cout << "Creation date modified.\n";
|
context.footnote ("Creation date modified.");
|
||||||
task.set ("entry", value);
|
task.set ("entry", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,13 +314,13 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
Date original (::atoi (task.get ("start").c_str ()));
|
Date original (::atoi (task.get ("start").c_str ()));
|
||||||
if (!original.sameDay (edited))
|
if (!original.sameDay (edited))
|
||||||
{
|
{
|
||||||
std::cout << "Start date modified.\n";
|
context.footnote ("Start date modified.");
|
||||||
task.set ("start", value);
|
task.set ("start", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Start date modified.\n";
|
context.footnote ("Start date modified.");
|
||||||
task.set ("start", value);
|
task.set ("start", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,7 +328,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (task.get ("start") != "")
|
if (task.get ("start") != "")
|
||||||
{
|
{
|
||||||
std::cout << "Start date removed.\n";
|
context.footnote ("Start date removed.");
|
||||||
task.remove ("start");
|
task.remove ("start");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,7 +344,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
Date original (::atoi (task.get ("end").c_str ()));
|
Date original (::atoi (task.get ("end").c_str ()));
|
||||||
if (!original.sameDay (edited))
|
if (!original.sameDay (edited))
|
||||||
{
|
{
|
||||||
std::cout << "Done date modified.\n";
|
context.footnote ("Done date modified.");
|
||||||
task.set ("end", value);
|
task.set ("end", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -319,7 +355,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (task.get ("end") != "")
|
if (task.get ("end") != "")
|
||||||
{
|
{
|
||||||
std::cout << "Done date removed.\n";
|
context.footnote ("Done date removed.");
|
||||||
task.setStatus (Task::pending);
|
task.setStatus (Task::pending);
|
||||||
task.remove ("end");
|
task.remove ("end");
|
||||||
}
|
}
|
||||||
@@ -336,13 +372,13 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
Date original (::atoi (task.get ("due").c_str ()));
|
Date original (::atoi (task.get ("due").c_str ()));
|
||||||
if (!original.sameDay (edited))
|
if (!original.sameDay (edited))
|
||||||
{
|
{
|
||||||
std::cout << "Due date modified.\n";
|
context.footnote ("Due date modified.");
|
||||||
task.set ("due", value);
|
task.set ("due", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Due date modified.\n";
|
context.footnote ("Due date modified.");
|
||||||
task.set ("due", value);
|
task.set ("due", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,11 +389,11 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
if (task.getStatus () == Task::recurring ||
|
if (task.getStatus () == Task::recurring ||
|
||||||
task.get ("parent") != "")
|
task.get ("parent") != "")
|
||||||
{
|
{
|
||||||
std::cout << "Cannot remove a due date from a recurring task.\n";
|
context.footnote ("Cannot remove a due date from a recurring task.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Due date removed.\n";
|
context.footnote ("Due date removed.");
|
||||||
task.remove ("due");
|
task.remove ("due");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,13 +410,13 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
Date original (::atoi (task.get ("until").c_str ()));
|
Date original (::atoi (task.get ("until").c_str ()));
|
||||||
if (!original.sameDay (edited))
|
if (!original.sameDay (edited))
|
||||||
{
|
{
|
||||||
std::cout << "Until date modified.\n";
|
context.footnote ("Until date modified.");
|
||||||
task.set ("until", value);
|
task.set ("until", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Until date modified.\n";
|
context.footnote ("Until date modified.");
|
||||||
task.set ("until", value);
|
task.set ("until", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -388,7 +424,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (task.get ("until") != "")
|
if (task.get ("until") != "")
|
||||||
{
|
{
|
||||||
std::cout << "Until date removed.\n";
|
context.footnote ("Until date removed.");
|
||||||
task.remove ("until");
|
task.remove ("until");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,7 +438,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
Duration d;
|
Duration d;
|
||||||
if (d.valid (value))
|
if (d.valid (value))
|
||||||
{
|
{
|
||||||
std::cout << "Recurrence modified.\n";
|
context.footnote ("Recurrence modified.");
|
||||||
if (task.get ("due") != "")
|
if (task.get ("due") != "")
|
||||||
{
|
{
|
||||||
task.set ("recur", value);
|
task.set ("recur", value);
|
||||||
@@ -416,7 +452,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Recurrence removed.\n";
|
context.footnote ("Recurrence removed.");
|
||||||
task.setStatus (Task::pending);
|
task.setStatus (Task::pending);
|
||||||
task.remove ("recur");
|
task.remove ("recur");
|
||||||
task.remove ("until");
|
task.remove ("until");
|
||||||
@@ -436,14 +472,14 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
Date original (::atoi (task.get ("wait").c_str ()));
|
Date original (::atoi (task.get ("wait").c_str ()));
|
||||||
if (!original.sameDay (edited))
|
if (!original.sameDay (edited))
|
||||||
{
|
{
|
||||||
std::cout << "Wait date modified.\n";
|
context.footnote ("Wait date modified.");
|
||||||
task.set ("wait", value);
|
task.set ("wait", value);
|
||||||
task.setStatus (Task::waiting);
|
task.setStatus (Task::waiting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Wait date modified.\n";
|
context.footnote ("Wait date modified.");
|
||||||
task.set ("wait", value);
|
task.set ("wait", value);
|
||||||
task.setStatus (Task::waiting);
|
task.setStatus (Task::waiting);
|
||||||
}
|
}
|
||||||
@@ -452,7 +488,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (task.get ("wait") != "")
|
if (task.get ("wait") != "")
|
||||||
{
|
{
|
||||||
std::cout << "Wait date removed.\n";
|
context.footnote ("Wait date removed.");
|
||||||
task.remove ("wait");
|
task.remove ("wait");
|
||||||
task.setStatus (Task::pending);
|
task.setStatus (Task::pending);
|
||||||
}
|
}
|
||||||
@@ -464,12 +500,12 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (value != "")
|
if (value != "")
|
||||||
{
|
{
|
||||||
std::cout << "Parent UUID modified.\n";
|
context.footnote ("Parent UUID modified.");
|
||||||
task.set ("parent", value);
|
task.set ("parent", value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Parent UUID removed.\n";
|
context.footnote ("Parent UUID removed.");
|
||||||
task.remove ("parent");
|
task.remove ("parent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -480,12 +516,12 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (value != "")
|
if (value != "")
|
||||||
{
|
{
|
||||||
std::cout << "Foreground color modified.\n";
|
context.footnote ("Foreground color modified.");
|
||||||
task.set ("fg", value);
|
task.set ("fg", value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Foreground color removed.\n";
|
context.footnote ("Foreground color removed.");
|
||||||
task.remove ("fg");
|
task.remove ("fg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -496,12 +532,12 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
{
|
{
|
||||||
if (value != "")
|
if (value != "")
|
||||||
{
|
{
|
||||||
std::cout << "Background color modified.\n";
|
context.footnote ("Background color modified.");
|
||||||
task.set ("bg", value);
|
task.set ("bg", value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Background color removed.\n";
|
context.footnote ("Background color removed.");
|
||||||
task.remove ("bg");
|
task.remove ("bg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -556,7 +592,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool editFile (Task& task)
|
bool CmdEdit::editFile (Task& task)
|
||||||
{
|
{
|
||||||
// Check for file permissions.
|
// Check for file permissions.
|
||||||
Directory location (context.config.get ("data.location"));
|
Directory location (context.config.get ("data.location"));
|
||||||
@@ -645,35 +681,3 @@ ARE_THESE_REALLY_HARMFUL:
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Introducing the Silver Bullet. This feature is the catch-all fixative for
|
|
||||||
// various other ills. This is like opening up the hood and going in with a
|
|
||||||
// wrench. To be used sparingly.
|
|
||||||
int handleEdit (std::string& outs)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
std::stringstream out;
|
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
|
||||||
handleRecurrence ();
|
|
||||||
Filter filter;
|
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
|
|
||||||
// Filter sequence.
|
|
||||||
std::vector <Task> all = tasks;
|
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
|
||||||
if (editFile (*task))
|
|
||||||
context.tdb.update (*task);
|
|
||||||
|
|
||||||
context.tdb.commit ();
|
|
||||||
context.tdb.unlock ();
|
|
||||||
|
|
||||||
outs = out.str ();
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
51
src/commands/CmdEdit.h
Normal file
51
src/commands/CmdEdit.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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_CMDEDIT
|
||||||
|
#define INCLUDED_CMDEDIT
|
||||||
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <Command.h>
|
||||||
|
#include <Task.h>
|
||||||
|
|
||||||
|
class CmdEdit : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CmdEdit ();
|
||||||
|
int execute (const std::string&, std::string&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string findValue (const std::string&, const std::string&);
|
||||||
|
std::string findDate (const std::string&, const std::string&);
|
||||||
|
std::string formatDate (Task&, const std::string&);
|
||||||
|
std::string formatTask (Task);
|
||||||
|
void parseTask (Task&, const std::string&);
|
||||||
|
bool editFile (Task&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -114,10 +114,6 @@ int CmdHelp::execute (const std::string& command_line, 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 edit ID");
|
|
||||||
view.set (row, 2, "Launches an editor to let you modify all aspects of a task directly, therefore it is to be used carefully.");
|
|
||||||
|
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 1, "task undo");
|
view.set (row, 1, "task undo");
|
||||||
view.set (row, 2, "Reverts the most recent action.");
|
view.set (row, 2, "Reverts the most recent action.");
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <Command.h>
|
#include <Command.h>
|
||||||
#include <CmdCustom.h>
|
#include <CmdCustom.h>
|
||||||
#include <CmdDiagnostics.h>
|
#include <CmdDiagnostics.h>
|
||||||
|
#include <CmdEdit.h>
|
||||||
#include <CmdExec.h>
|
#include <CmdExec.h>
|
||||||
#include <CmdHelp.h>
|
#include <CmdHelp.h>
|
||||||
#include <CmdInfo.h>
|
#include <CmdInfo.h>
|
||||||
@@ -50,6 +51,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
|||||||
|
|
||||||
c = new CmdCompletionVersion (); all[c->keyword ()] = c;
|
c = new CmdCompletionVersion (); all[c->keyword ()] = c;
|
||||||
c = new CmdDiagnostics (); all[c->keyword ()] = c;
|
c = new CmdDiagnostics (); all[c->keyword ()] = c;
|
||||||
|
c = new CmdEdit (); all[c->keyword ()] = c;
|
||||||
c = new CmdExec (); all[c->keyword ()] = c;
|
c = new CmdExec (); all[c->keyword ()] = c;
|
||||||
c = new CmdHelp (); all[c->keyword ()] = c;
|
c = new CmdHelp (); all[c->keyword ()] = c;
|
||||||
c = new CmdInfo (); all[c->keyword ()] = c;
|
c = new CmdInfo (); all[c->keyword ()] = c;
|
||||||
|
|||||||
@@ -88,9 +88,6 @@ int deltaTags (Task&);
|
|||||||
int deltaAttributes (Task&);
|
int deltaAttributes (Task&);
|
||||||
int deltaSubstitutions (Task&);
|
int deltaSubstitutions (Task&);
|
||||||
|
|
||||||
// edit.cpp
|
|
||||||
int handleEdit (std::string&);
|
|
||||||
|
|
||||||
// report.cpp
|
// report.cpp
|
||||||
int handleReportSummary (std::string&);
|
int handleReportSummary (std::string&);
|
||||||
int handleReportCalendar (std::string&);
|
int handleReportCalendar (std::string&);
|
||||||
|
|||||||
Reference in New Issue
Block a user