mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup - TDB removal
- TDB removed from all code, but source kept for further reference.
This commit is contained in:
parent
fc7b344a8b
commit
9776495286
13 changed files with 71 additions and 89 deletions
|
@ -9,4 +9,4 @@ task_SOURCES = Att.cpp Cmd.cpp Config.cpp Context.cpp Date.cpp Duration.cpp \
|
|||
Grid.h Keymap.h Location.h Nibbler.h Record.h Sequence.h \
|
||||
StringTable.h Subst.h Task.h TDB2.h Table.h Timer.h color.h \
|
||||
i18n.h main.h text.h util.h \
|
||||
T.cpp T.h TDB.cpp TDB.h
|
||||
T.cpp T.h
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include <pwd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "main.h"
|
||||
|
@ -546,7 +544,7 @@ std::string handleStart ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string handleStop (TDB& tdb, T& task)
|
||||
std::string handleStop ()
|
||||
{
|
||||
std::stringstream out;
|
||||
/*
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "Date.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
@ -93,6 +92,7 @@ static std::string findDate (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Obsolete - use Task::statusToText
|
||||
static std::string formatStatus (T& task)
|
||||
{
|
||||
switch (task.getStatus ())
|
||||
|
@ -496,9 +496,10 @@ static void parseTask (T& task, const std::string& after)
|
|||
// 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.
|
||||
std::string handleEdit (TDB& tdb, T& task)
|
||||
std::string handleEdit ()
|
||||
{
|
||||
std::stringstream out;
|
||||
/*
|
||||
std::vector <T> all;
|
||||
tdb.allPendingT (all);
|
||||
|
||||
|
@ -587,6 +588,7 @@ ARE_THESE_REALLY_HARMFUL:
|
|||
unlink (file);
|
||||
}
|
||||
|
||||
*/
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <unistd.h>
|
||||
#include "Date.h"
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "main.h"
|
||||
|
@ -182,9 +181,10 @@ static void decorateTask (T& task)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string importTask_1_4_3 (
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
const std::vector <std::string>& lines)
|
||||
{
|
||||
/*
|
||||
std::vector <std::string> failed;
|
||||
|
||||
std::vector <std::string>::const_iterator it;
|
||||
|
@ -316,8 +316,10 @@ static std::string importTask_1_4_3 (
|
|||
failed.push_back (*it);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
std::stringstream out;
|
||||
/*
|
||||
out << "Imported "
|
||||
<< (lines.size () - failed.size () - 1)
|
||||
<< " tasks successfully, with "
|
||||
|
@ -331,15 +333,16 @@ static std::string importTask_1_4_3 (
|
|||
join (bad, "\n", failed);
|
||||
return out.str () + "\nCould not import:\n\n" + bad;
|
||||
}
|
||||
|
||||
*/
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string importTask_1_5_0 (
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
const std::vector <std::string>& lines)
|
||||
{
|
||||
/*
|
||||
std::vector <std::string> failed;
|
||||
|
||||
std::vector <std::string>::const_iterator it;
|
||||
|
@ -477,7 +480,9 @@ static std::string importTask_1_5_0 (
|
|||
}
|
||||
}
|
||||
|
||||
*/
|
||||
std::stringstream out;
|
||||
/*
|
||||
out << "Imported "
|
||||
<< (lines.size () - failed.size () - 1)
|
||||
<< " tasks successfully, with "
|
||||
|
@ -491,15 +496,17 @@ static std::string importTask_1_5_0 (
|
|||
join (bad, "\n", failed);
|
||||
return out.str () + "\nCould not import:\n\n" + bad;
|
||||
}
|
||||
*/
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string importTask_1_6_0 (
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
const std::vector <std::string>& lines)
|
||||
{
|
||||
/*
|
||||
std::vector <std::string> failed;
|
||||
|
||||
std::vector <std::string>::const_iterator it;
|
||||
|
@ -636,8 +643,10 @@ static std::string importTask_1_6_0 (
|
|||
failed.push_back (*it);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
std::stringstream out;
|
||||
/*
|
||||
out << "Imported "
|
||||
<< (lines.size () - failed.size () - 1)
|
||||
<< " tasks successfully, with "
|
||||
|
@ -651,15 +660,16 @@ static std::string importTask_1_6_0 (
|
|||
join (bad, "\n", failed);
|
||||
return out.str () + "\nCould not import:\n\n" + bad;
|
||||
}
|
||||
|
||||
*/
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string importTaskCmdLine (
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
const std::vector <std::string>& lines)
|
||||
{
|
||||
/*
|
||||
std::vector <std::string> failed;
|
||||
|
||||
std::vector <std::string>::const_iterator it;
|
||||
|
@ -683,8 +693,10 @@ static std::string importTaskCmdLine (
|
|||
failed.push_back (line);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
std::stringstream out;
|
||||
/*
|
||||
out << "Imported "
|
||||
<< (lines.size () - failed.size ())
|
||||
<< " tasks successfully, with "
|
||||
|
@ -698,15 +710,17 @@ static std::string importTaskCmdLine (
|
|||
join (bad, "\n", failed);
|
||||
return out.str () + "\nCould not import:\n\n" + bad;
|
||||
}
|
||||
*/
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string importTodoSh_2_0 (
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
const std::vector <std::string>& lines)
|
||||
{
|
||||
/*
|
||||
std::vector <std::string> failed;
|
||||
|
||||
std::vector <std::string>::const_iterator it;
|
||||
|
@ -804,8 +818,10 @@ static std::string importTodoSh_2_0 (
|
|||
failed.push_back (*it);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
std::stringstream out;
|
||||
/*
|
||||
out << "Imported "
|
||||
<< (lines.size () - failed.size ())
|
||||
<< " tasks successfully, with "
|
||||
|
@ -819,15 +835,16 @@ static std::string importTodoSh_2_0 (
|
|||
join (bad, "\n", failed);
|
||||
return out.str () + "\nCould not import:\n\n" + bad;
|
||||
}
|
||||
|
||||
*/
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string importText (
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
const std::vector <std::string>& lines)
|
||||
{
|
||||
/*
|
||||
std::vector <std::string> failed;
|
||||
int count = 0;
|
||||
|
||||
|
@ -865,8 +882,10 @@ static std::string importText (
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
std::stringstream out;
|
||||
/*
|
||||
out << "Imported "
|
||||
<< count
|
||||
<< " tasks successfully, with "
|
||||
|
@ -880,15 +899,17 @@ static std::string importText (
|
|||
join (bad, "\n", failed);
|
||||
return out.str () + "\nCould not import:\n\n" + bad;
|
||||
}
|
||||
*/
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string importCSV (
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
const std::vector <std::string>& lines)
|
||||
{
|
||||
/*
|
||||
std::vector <std::string> failed;
|
||||
|
||||
// Set up mappings. Assume no fields match.
|
||||
|
@ -1107,8 +1128,10 @@ static std::string importCSV (
|
|||
failed.push_back (*it);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
std::stringstream out;
|
||||
/*
|
||||
out << "Imported "
|
||||
<< (lines.size () - failed.size () - 1)
|
||||
<< " tasks successfully, with "
|
||||
|
@ -1122,6 +1145,7 @@ static std::string importCSV (
|
|||
join (bad, "\n", failed);
|
||||
return out.str () + "\nCould not import:\n\n" + bad;
|
||||
}
|
||||
*/
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
|
59
src/main.cpp
59
src/main.cpp
|
@ -40,7 +40,6 @@
|
|||
#include "Date.h"
|
||||
#include "Duration.h"
|
||||
#include "Table.h"
|
||||
#include "TDB.h"
|
||||
#include "T.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
@ -117,54 +116,9 @@ int main (int argc, char** argv)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void updateShadowFile (TDB& tdb)
|
||||
// TODO Obsolete
|
||||
void updateShadowFile ()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Determine if shadow file is enabled.
|
||||
std::string shadowFile = expandPath (context.config.get ("shadow.file"));
|
||||
if (shadowFile != "")
|
||||
{
|
||||
std::string oldCurses = context.config.get ("curses");
|
||||
std::string oldColor = context.config.get ("color");
|
||||
context.config.set ("curses", "off");
|
||||
context.config.set ("color", "off");
|
||||
|
||||
// Run report. Use shadow.command, using default.command as a fallback
|
||||
// with "list" as a default.
|
||||
std::string command = context.config.get ("shadow.command",
|
||||
context.config.get ("default.command", "list"));
|
||||
std::vector <std::string> args;
|
||||
split (args, command, ' ');
|
||||
std::string result = runTaskCommand (args, tdb);
|
||||
|
||||
std::ofstream out (shadowFile.c_str ());
|
||||
if (out.good ())
|
||||
{
|
||||
out << result;
|
||||
out.close ();
|
||||
}
|
||||
else
|
||||
throw std::string ("Could not write file '") + shadowFile + "'";
|
||||
|
||||
context.config.set ("curses", oldCurses);
|
||||
context.config.set ("color", oldColor);
|
||||
}
|
||||
|
||||
// Optionally display a notification that the shadow file was updated.
|
||||
if (context.config.get (std::string ("shadow.notify"), false))
|
||||
std::cout << "[Shadow file '" << shadowFile << "' updated]" << std::endl;
|
||||
}
|
||||
|
||||
catch (std::string& error)
|
||||
{
|
||||
std::cerr << error << std::endl;
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Unknown error." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -172,10 +126,11 @@ void updateShadowFile (TDB& tdb)
|
|||
std::string runTaskCommand (
|
||||
int argc,
|
||||
char** argv,
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
bool gc /* = true */,
|
||||
bool shadow /* = true */)
|
||||
{
|
||||
/*
|
||||
std::vector <std::string> args;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
if (strncmp (argv[i], "rc:", 3) &&
|
||||
|
@ -186,16 +141,19 @@ std::cout << "arg=" << argv[i] << std::endl;
|
|||
}
|
||||
|
||||
return runTaskCommand (args, tdb, gc, shadow);
|
||||
*/
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO Obsolete
|
||||
std::string runTaskCommand (
|
||||
std::vector <std::string>& args,
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
bool gc /* = false */,
|
||||
bool shadow /* = false */)
|
||||
{
|
||||
/*
|
||||
// If argc == 1 and there is a default.command, use it. Otherwise use
|
||||
// argc/argv.
|
||||
std::string defaultCommand = context.config.get ("default.command");
|
||||
|
@ -215,6 +173,7 @@ std::string runTaskCommand (
|
|||
|
||||
bool gcMod = false; // Change occurred by way of gc.
|
||||
bool cmdMod = false; // Change occurred by way of command type.
|
||||
*/
|
||||
std::string out;
|
||||
/*
|
||||
// Read-only commands with no side effects.
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <sys/types.h>
|
||||
#include "Context.h"
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "Table.h"
|
||||
#include "Date.h"
|
||||
#include "color.h"
|
||||
|
@ -49,18 +48,20 @@ bool isCustomReport (const std::string&);
|
|||
void allCustomReports (std::vector <std::string>&);
|
||||
|
||||
// task.cpp
|
||||
void gatherNextTasks (const TDB&, T&, std::vector <T>&, std::vector <int>&);
|
||||
void gatherNextTasks (/*const TDB&,*/ T&, std::vector <T>&, std::vector <int>&);
|
||||
void onChangeCallback ();
|
||||
/*
|
||||
std::string runTaskCommand (int, char**, TDB&, bool gc = true, bool shadow = true);
|
||||
std::string runTaskCommand (std::vector <std::string>&, TDB&, bool gc = false, bool shadow = false);
|
||||
*/
|
||||
|
||||
// recur.cpp
|
||||
void handleRecurrence ();
|
||||
Date getNextRecurrence (Date&, std::string&);
|
||||
bool generateDueDates (T&, std::vector <Date>&);
|
||||
void updateRecurrenceMask (TDB&, std::vector <T>&, T&);
|
||||
void updateRecurrenceMask (/*TDB&,*/ std::vector <T>&, T&);
|
||||
int getDueState (const std::string&);
|
||||
void nag (TDB&, T&);
|
||||
void nag (/*TDB&,*/ T&);
|
||||
|
||||
// command.cpp
|
||||
std::string handleAdd ();
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
#include "Context.h"
|
||||
#include "Date.h"
|
||||
#include "Duration.h"
|
||||
#include "Table.h"
|
||||
#include "TDB.h"
|
||||
#include "T.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
@ -330,10 +328,11 @@ Date getNextRecurrence (Date& current, std::string& period)
|
|||
// When the status of a recurring child task changes, the parent task must
|
||||
// update it's mask.
|
||||
void updateRecurrenceMask (
|
||||
TDB& tdb,
|
||||
// TDB& tdb,
|
||||
std::vector <T>& all,
|
||||
T& task)
|
||||
{
|
||||
/*
|
||||
std::string parent = task.getAttribute ("parent");
|
||||
if (parent != "")
|
||||
{
|
||||
|
@ -370,6 +369,7 @@ void updateRecurrenceMask (
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -399,8 +399,9 @@ int getDueState (const std::string& due)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void nag (TDB& tdb, T& task)
|
||||
void nag (/*TDB& tdb,*/ T& task)
|
||||
{
|
||||
/*
|
||||
std::string nagMessage = context.config.get ("nag", std::string (""));
|
||||
if (nagMessage != "")
|
||||
{
|
||||
|
@ -456,6 +457,7 @@ void nag (TDB& tdb, T& task)
|
|||
// All the excuses are made, all that remains is to nag the user.
|
||||
std::cout << nagMessage << std::endl;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "Context.h"
|
||||
#include "Date.h"
|
||||
#include "Table.h"
|
||||
#include "TDB.h"
|
||||
#include "T.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
@ -2431,7 +2430,7 @@ std::string handleReportStats ()
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void gatherNextTasks (
|
||||
const TDB& tdb,
|
||||
// const TDB& tdb,
|
||||
T& task,
|
||||
std::vector <T>& pending,
|
||||
std::vector <int>& all)
|
||||
|
|
|
@ -3,12 +3,11 @@ PROJECT = t.t t2.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
|||
cmd.t config.t
|
||||
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||
LFLAGS = -L/usr/local/lib -lncurses
|
||||
OBJECTS = ../TDB.o ../TDB2.o ../T.o ../Task.o ../parse.o ../text.o ../Date.o \
|
||||
../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o \
|
||||
OBJECTS = ../TDB2.o ../T.o ../Task.o ../parse.o ../text.o ../Date.o ../Table.o \
|
||||
../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o ../Cmd.o \
|
||||
../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \
|
||||
../Filter.o ../Context.o ../Keymap.o ../Cmd.o ../command.o \
|
||||
../report.o ../Table.o ../Grid.o ../color.o ../rules.o ../recur.o \
|
||||
../interactive.o
|
||||
../Filter.o ../Context.o ../Keymap.o ../command.o ../interactive.o \
|
||||
../report.o ../Grid.o ../color.o ../rules.o ../recur.o
|
||||
|
||||
all: $(PROJECT)
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "TDB.h"
|
||||
#include "T.h"
|
||||
#include "main.h"
|
||||
#include "test.h"
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "TDB.h"
|
||||
#include "main.h"
|
||||
#include "test.h"
|
||||
|
||||
|
@ -40,6 +39,7 @@ int main (int argc, char** argv)
|
|||
|
||||
try
|
||||
{
|
||||
/*
|
||||
// Remove any residual test file.
|
||||
unlink ("./pending.data");
|
||||
unlink ("./completed.data");
|
||||
|
@ -113,6 +113,7 @@ int main (int argc, char** argv)
|
|||
|
||||
// GC the files.
|
||||
t.is (tdb.gc (), 1, "1 <- TDB::gc");
|
||||
*/
|
||||
}
|
||||
|
||||
catch (std::string& error)
|
||||
|
|
|
@ -36,10 +36,8 @@
|
|||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "Date.h"
|
||||
#include "Table.h"
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "text.h"
|
||||
#include "main.h"
|
||||
#include "i18n.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue