mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
FF4 - snapshot
This commit is contained in:
parent
04f60a4d8c
commit
3a9c98d342
11 changed files with 127 additions and 30 deletions
|
@ -34,7 +34,7 @@ class Att
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Att (); // Default constructor
|
Att (); // Default constructor
|
||||||
Att (const std::string&, const std::string&);
|
Att (const std::string&, const std::string&); // Simple constructor
|
||||||
Att (const Att&); // Copy constructor
|
Att (const Att&); // Copy constructor
|
||||||
Att& operator= (const Att&); // Assignment operator
|
Att& operator= (const Att&); // Assignment operator
|
||||||
~Att (); // Destructor
|
~Att (); // Destructor
|
||||||
|
|
|
@ -25,11 +25,22 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <pwd.h>
|
||||||
#include "Context.h"
|
#include "Context.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "../auto.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Context::Context ()
|
Context::Context ()
|
||||||
{
|
{
|
||||||
|
// Set up randomness.
|
||||||
|
#ifdef HAVE_SRANDOM
|
||||||
|
srandom (time (NULL));
|
||||||
|
#else
|
||||||
|
srand (time (NULL));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -67,24 +78,39 @@ Context::~Context ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Context::initialize ()
|
void Context::initialize (int argc, char** argv)
|
||||||
{
|
{
|
||||||
throw std::string ("unimplemented Context::initialize");
|
// Load the config file from the home directory. If the file cannot be
|
||||||
// TODO Load config.
|
// found, offer to create a sample one.
|
||||||
|
loadCorrectConfigFile (argc, argv);
|
||||||
|
|
||||||
|
// When redirecting output to a file, do not use color, curses.
|
||||||
|
if (!isatty (fileno (stdout)))
|
||||||
|
{
|
||||||
|
config.set ("curses", "off");
|
||||||
|
|
||||||
|
if (! config.get (std::string ("_forcecolor"), false))
|
||||||
|
config.set ("color", "off");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Handle "--version, -v" right here.
|
||||||
|
|
||||||
|
// init TDB.
|
||||||
|
std::string location = config.get ("data.location");
|
||||||
|
std::vector <std::string> all;
|
||||||
|
split (all, location, ',');
|
||||||
|
foreach (path, all)
|
||||||
|
tdb.location (expandPath (*path));
|
||||||
|
|
||||||
|
// Allow user override of file locking. Solaris/NFS machines may want this.
|
||||||
|
if (! config.get ("locking", true))
|
||||||
|
tdb.noLock ();
|
||||||
|
|
||||||
// TODO Load pending.data.
|
// TODO Load pending.data.
|
||||||
// TODO Load completed.data.
|
// TODO Load completed.data.
|
||||||
// TODO Load deleted.data.
|
// TODO Load deleted.data.
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
int Context::commandLine (int argc, char** argv)
|
|
||||||
{
|
|
||||||
throw std::string ("unimplemented Context::commandLine");
|
|
||||||
// TODO Support rc: override.
|
|
||||||
// TODO Handle "--version, -v" right here.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Context::run ()
|
int Context::run ()
|
||||||
{
|
{
|
||||||
|
@ -97,4 +123,29 @@ int Context::run ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Context::loadCorrectConfigFile (int argc, char** argv)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
|
if (! strncmp (argv[i], "rc:", 3))
|
||||||
|
{
|
||||||
|
if (! access (&(argv[i][3]), F_OK))
|
||||||
|
{
|
||||||
|
std::string file = &(argv[i][3]);
|
||||||
|
config.load (file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw std::string ("Could not read configuration file '") + &(argv[i][3]) + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct passwd* pw = getpwuid (getuid ());
|
||||||
|
if (!pw)
|
||||||
|
throw std::string ("Could not read home directory from passwd file.");
|
||||||
|
|
||||||
|
std::string file = pw->pw_dir;
|
||||||
|
config.createDefault (file);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
#include "Keymap.h"
|
#include "Keymap.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Sequence.h"
|
#include "Sequence.h"
|
||||||
#include "TDB.h"
|
|
||||||
#include "T.h"
|
#include "T.h"
|
||||||
|
#include "TDB.h"
|
||||||
|
|
||||||
|
|
||||||
class Context
|
class Context
|
||||||
|
@ -43,10 +43,12 @@ public:
|
||||||
Context& operator= (const Context&); // Assignment operator
|
Context& operator= (const Context&); // Assignment operator
|
||||||
~Context (); // Destructor
|
~Context (); // Destructor
|
||||||
|
|
||||||
void initialize ();
|
void initialize (int, char**);
|
||||||
int commandLine (int, char**);
|
|
||||||
int run ();
|
int run ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void loadCorrectConfigFile (int, char**);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Config config;
|
Config config;
|
||||||
Filter filter;
|
Filter filter;
|
||||||
|
|
|
@ -3,7 +3,7 @@ CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti -fstack-check
|
||||||
LFLAGS =
|
LFLAGS =
|
||||||
LIBS =
|
LIBS =
|
||||||
OBJECTS = main.o Context.o TDB.o T.o Sequence.o Filter.o Att.o Keymap.o \
|
OBJECTS = main.o Context.o TDB.o T.o Sequence.o Filter.o Att.o Keymap.o \
|
||||||
../util.o ../text.o ../Config.o ../Date.o
|
Record.o ../util.o ../text.o ../Config.o ../Date.o
|
||||||
|
|
||||||
all: $(PROJECT)
|
all: $(PROJECT)
|
||||||
|
|
||||||
|
|
|
@ -57,4 +57,9 @@ Record::~Record ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Record::parse (const std::string& input)
|
||||||
|
{
|
||||||
|
throw std::string ("unimplemented Record::parse");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -36,7 +36,11 @@ public:
|
||||||
Record (); // Default constructor
|
Record (); // Default constructor
|
||||||
Record (const Record&); // Copy constructor
|
Record (const Record&); // Copy constructor
|
||||||
Record& operator= (const Record&); // Assignment operator
|
Record& operator= (const Record&); // Assignment operator
|
||||||
~Record (); // Destructor
|
virtual ~Record (); // Destructor
|
||||||
|
|
||||||
|
virtual std::string composeF4 () = 0;
|
||||||
|
virtual std::string composeCSV () = 0;
|
||||||
|
void parse (const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector <Att> mAtts;
|
std::vector <Att> mAtts;
|
||||||
|
|
|
@ -34,11 +34,13 @@ T::T ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/*
|
||||||
T::T (const T& other)
|
T::T (const T& other)
|
||||||
{
|
{
|
||||||
throw std::string ("unimplemented T::T");
|
throw std::string ("unimplemented T::T");
|
||||||
// mOne = other.mOne;
|
// mOne = other.mOne;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
T::T (const std::string& input)
|
T::T (const std::string& input)
|
||||||
|
@ -78,9 +80,3 @@ std::string T::composeCSV ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void T::parse (const std::string& input)
|
|
||||||
{
|
|
||||||
throw std::string ("unimplemented T::parse");
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
|
@ -28,19 +28,19 @@
|
||||||
#define INCLUDED_T
|
#define INCLUDED_T
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "Record.h"
|
||||||
|
|
||||||
class T
|
class T : public Record
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T (); // Default constructor
|
T (); // Default constructor
|
||||||
T (const T&); // Copy constructor
|
// T (const T&); // Copy constructor
|
||||||
T (const std::string&); // Parse
|
T (const std::string&); // Parse
|
||||||
T& operator= (const T&); // Assignment operator
|
T& operator= (const T&); // Assignment operator
|
||||||
~T (); // Destructor
|
~T (); // Destructor
|
||||||
|
|
||||||
std::string composeF4 ();
|
std::string composeF4 ();
|
||||||
std::string composeCSV ();
|
std::string composeCSV ();
|
||||||
void parse (const std::string&);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,10 +26,14 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
#include "TDB.h"
|
#include "TDB.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
TDB::TDB ()
|
TDB::TDB ()
|
||||||
|
: mLock (true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +64,11 @@ TDB::~TDB ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void TDB::location (const std::string& path)
|
void TDB::location (const std::string& path)
|
||||||
{
|
{
|
||||||
throw std::string ("unimplemented TDB::location");
|
if (access (expandPath (path).c_str (), F_OK))
|
||||||
|
throw std::string ("Data location '") +
|
||||||
|
path +
|
||||||
|
"' does not exist, or is not readable and writable.";
|
||||||
|
|
||||||
mLocations.push_back (path);
|
mLocations.push_back (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,3 +102,27 @@ void TDB::upgrade ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void TDB::noLock ()
|
||||||
|
{
|
||||||
|
mLock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void TDB::getPendingFiles (std::vector <std::string> files)
|
||||||
|
{
|
||||||
|
files.clear ();
|
||||||
|
|
||||||
|
foreach (location, mLocations)
|
||||||
|
files.push_back (*location + "/pending.data");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void TDB::getCompletedFiles (std::vector <std::string> files)
|
||||||
|
{
|
||||||
|
files.clear ();
|
||||||
|
|
||||||
|
foreach (location, mLocations)
|
||||||
|
files.push_back (*location + "/completed.data");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -46,8 +46,16 @@ public:
|
||||||
int commit ();
|
int commit ();
|
||||||
void upgrade ();
|
void upgrade ();
|
||||||
|
|
||||||
|
void noLock ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void getPendingFiles (std::vector <std::string>);
|
||||||
|
void getCompletedFiles (std::vector <std::string>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector <std::string> mLocations;
|
std::vector <std::string> mLocations;
|
||||||
|
bool mLock;
|
||||||
|
|
||||||
// TODO Need cache of raw file contents.
|
// TODO Need cache of raw file contents.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@ int main (int argc, char** argv)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Context c;
|
Context c;
|
||||||
c.initialize ();
|
c.initialize (argc, argv);
|
||||||
c.commandLine (argc, argv);
|
|
||||||
c.run ();
|
c.run ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue