Merge branch '1.9.0' of tasktools.org:task into 1.9.0

Conflicts:
	src/Context.cpp
This commit is contained in:
Federico Hernandez
2010-01-16 23:45:07 +01:00
10 changed files with 85 additions and 32 deletions

34
doc/misc/script-color.txt Normal file
View File

@@ -0,0 +1,34 @@
Hello. This is a demonstration of the
task program color capabilities coming
in version 1.9.
task color The color command shows the various
supported colors. For this you will
need an xterm with 256-color support,
or an equivalent.
This demo uses iTerm running on Snow
Leopard.
task add Prepare 1.9 for release Let's create a few tasks, to illustrate
task add Update the various docs the features. Five should be enough.
task add Run the regression tests
task add Make the packages
task add Upload to distributions
--- NOTES
16-color mode
upgrade
blending
alternate lines
--- NOTES
task ls Okay, let's color any tasks that
mention tests a nice medium blue.
echo 'color.keyword.test=color23' >> ~/.taskrc

View File

@@ -62,17 +62,17 @@ std::string Config::defaults =
"annotation.details=2 # Level of verbosity for annotations in reports\n" "annotation.details=2 # Level of verbosity for annotations in reports\n"
"next=2 # How many tasks per project in next report\n" "next=2 # How many tasks per project in next report\n"
"bulk=2 # > 2 tasks considered 'a lot', for confirmation\n" "bulk=2 # > 2 tasks considered 'a lot', for confirmation\n"
"nag=You have higher priority tasks. # Nag message to keep you honest\n" "nag=You have higher priority tasks. # Nag message to keep you honest\n" // TODO
"\n" "\n"
"# Dates\n" "# Dates\n"
"dateformat=m/d/Y # Preferred input and display date format\n" "dateformat=m/d/Y # Preferred input and display date format\n"
"#reportdateformat=m/d/Y # Preferred input and display date format\n" "#reportdateformat=m/d/Y # Preferred display date format for repors\n"
"weekstart=Sunday # Sunday or Monday only\n" "weekstart=Sunday # Sunday or Monday only\n" // TODO
"displayweeknumber=yes # Show week numbers on calendar\n" "displayweeknumber=yes # Show week numbers on calendar\n" // TODO
"due=7 # Task is considered due in 7 days\n" "due=7 # Task is considered due in 7 days\n"
"#calendar.details=yes # Calendar shows information for tasks w/due dates\n" "#calendar.details=yes # Calendar shows information for tasks w/due dates\n"
"#calendar.details.report=list # Report to use when showing task information in cal\n" "#calendar.details.report=list # Report to use when showing task information in cal\n" // TODO
"#monthsperline=3 # Number of calendar months on a line\n" "#monthsperline=3 # Number of calendar months on a line\n" // TODO
"\n" "\n"
"# Color controls.\n" "# Color controls.\n"
"color=on # Enable color\n" "color=on # Enable color\n"
@@ -101,21 +101,22 @@ std::string Config::defaults =
"color.history.delete=on yellow # Color of deleted tasks in the history reports\n" "color.history.delete=on yellow # Color of deleted tasks in the history reports\n"
"color.history.done=on green # Color of completed tasks in the history reports\n" "color.history.done=on green # Color of completed tasks in the history reports\n"
"\n" "\n"
"# Shadow file support\n"
"#shadow.file=/tmp/shadow.txt # Location of shadow file\n" "#shadow.file=/tmp/shadow.txt # Location of shadow file\n"
"#shadow.command=list # Task command for shadow file\n" "#shadow.command=list # Task command for shadow file\n"
"#shadow.notify=on # Footnote when updated\n" "#shadow.notify=on # Footnote when updated\n"
"\n" "\n"
"#default.project=foo # Default project for 'add' command\n" "#default.project=foo # Default project for 'add' command\n"
"#default.priority=M # Default priority for 'add' command\n" "#default.priority=M # Default priority for 'add' command\n"
"default.command=list # When no arguments are specified\n" "default.command=list # When no arguments are specified\n" // TODO
"\n" "\n"
"_forcecolor=no # Forces color to be on, even for non TTY output\n" "_forcecolor=no # Forces color to be on, even for non TTY output\n"
"blanklines=true # Use more whitespace in output\n" "blanklines=true # Use more whitespace in output\n"
"complete.all.projects=no # Include old project names in 'projects' command\n" "complete.all.projects=no # Include old project names in 'projects' command\n" // TODO
"complete.all.tags=no # Include old tag names in 'tags' command\n" "complete.all.tags=no # Include old tag names in 'tags' command\n" // TODO
"debug=no # Display diagnostics\n" "debug=no # Display diagnostics\n"
"fontunderline=yes # Uses underlines rather than -------\n" "fontunderline=yes # Uses underlines rather than -------\n"
"shell.prompt=task> # Prompt used by the shell command\n" "shell.prompt=task> # Prompt used by the shell command\n" // TODO
"\n" "\n"
"# Import heuristics - alternate names for fields (comma-separated list of names)\n" "# Import heuristics - alternate names for fields (comma-separated list of names)\n"
"#import.synonym.bg=?\n" "#import.synonym.bg=?\n"
@@ -133,12 +134,13 @@ std::string Config::defaults =
"#import.synonym.tags=?\n" "#import.synonym.tags=?\n"
"#import.synonym.uuid=?\n" "#import.synonym.uuid=?\n"
"\n" "\n"
"# Aliases - alternate names for commands\n"
"alias.rm=delete # Alias for the delete command\n" "alias.rm=delete # Alias for the delete command\n"
"\n" "\n"
"# Fields: id,uuid,project,priority,priority_long,entry,entry_time,\n" "# Fields: id,uuid,project,priority,priority_long,entry,entry_time,\n" // TODO
"# start,entry_time,due,recur,recurrence_indicator,age,\n" "# start,entry_time,due,recur,recurrence_indicator,age,\n" // TODO
"# age_compact,active,tags,tag_indicator,description,\n" "# age_compact,active,tags,tag_indicator,description,\n" // TODO
"# description_only,end,end_time\n" "# description_only,end,end_time\n" // TODO
"# Description: This report is ...\n" "# Description: This report is ...\n"
"# Sort: due+,priority-,project+\n" "# Sort: due+,priority-,project+\n"
"# Filter: pro:x pri:H +bug limit:10\n" "# Filter: pro:x pri:H +bug limit:10\n"
@@ -321,7 +323,7 @@ void Config::parse (const std::string& input, int nest /* = 1 */)
if (included.is_absolute ()) if (included.is_absolute ())
{ {
if (included.readable ()) if (included.readable ())
this->load (included.data, nest + 1); this->load (included, nest + 1);
else else
throw std::string ("Could not read include file '") + included.data + "'"; throw std::string ("Could not read include file '") + included.data + "'";
} }

View File

@@ -125,7 +125,7 @@ void Context::initialize ()
// init TDB. // init TDB.
tdb.clear (); tdb.clear ();
std::vector <std::string> all; std::vector <std::string> all;
split (all, location.data, ','); split (all, location, ',');
foreach (path, all) foreach (path, all)
tdb.location (*path); tdb.location (*path);
} }
@@ -372,7 +372,7 @@ void Context::loadCorrectConfigFile ()
file_override = *arg; file_override = *arg;
rc = File (arg->substr (3)); rc = File (arg->substr (3));
home = rc.data; home = rc;
std::string::size_type last_slash = rc.data.rfind ("/"); std::string::size_type last_slash = rc.data.rfind ("/");
if (last_slash != std::string::npos) if (last_slash != std::string::npos)
home = rc.data.substr (0, last_slash); home = rc.data.substr (0, last_slash);
@@ -387,7 +387,7 @@ void Context::loadCorrectConfigFile ()
// Load rc file. // Load rc file.
config.clear (); // Dump current values. config.clear (); // Dump current values.
config.load (rc.data); // Load new file. config.load (rc); // Load new file.
if (config.get ("data.location") != "") if (config.get ("data.location") != "")
data = Directory (config.get ("data.location")); data = Directory (config.get ("data.location"));
@@ -416,20 +416,20 @@ void Context::loadCorrectConfigFile ()
+ rc.data + rc.data
+ " created, so task can proceed?")) + " created, so task can proceed?"))
{ {
config.createDefaultRC (rc.data, data.data); config.createDefaultRC (rc, data);
} }
else else
throw std::string ("Cannot proceed without rc file."); throw std::string ("Cannot proceed without rc file.");
} }
// Create data location, if necessary. // Create data location, if necessary.
config.createDefaultData (data.data); config.createDefaultData (data);
// TODO find out why this was done twice - see tw #355 // TODO find out why this was done twice - see tw #355
// Load rc file. // Load rc file.
//config.clear (); // Dump current values. //config.clear (); // Dump current values.
//config.setDefaults (); // Add in the custom reports. //config.setDefaults (); // Add in the custom reports.
//config.load (rc.data); // Load new file. //config.load (rc); // Load new file.
// Apply overrides of type: "rc.name:value", or "rc.name=value". // Apply overrides of type: "rc.name:value", or "rc.name=value".
std::vector <std::string> filtered; std::vector <std::string> filtered;

View File

@@ -65,6 +65,12 @@ Path& Path::operator= (const Path& other)
return *this; return *this;
} }
////////////////////////////////////////////////////////////////////////////////
Path::operator std::string () const
{
return data;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Path::name () const std::string Path::name () const
{ {

View File

@@ -39,6 +39,8 @@ public:
virtual ~Path (); virtual ~Path ();
Path& operator= (const Path&); Path& operator= (const Path&);
operator std::string () const;
std::string name () const; std::string name () const;
std::string parent () const; std::string parent () const;
std::string extension () const; std::string extension () const;

View File

@@ -114,7 +114,7 @@ void TDB::location (const std::string& path)
path + path +
"' does not exist, or is not readable and writable."; "' does not exist, or is not readable and writable.";
mLocations.push_back (Location (d.data)); mLocations.push_back (Location (d));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -1535,7 +1535,7 @@ int handleReportCalendar (std::string &outs)
// task cal 2010 // task cal 2010
monthsToDisplay = 12; monthsToDisplay = 12;
mFrom = 1; mFrom = 1;
yFrom = atoi( context.args[1].data()); yFrom = atoi (context.args[1].c_str ());
} }
} }
else if (numberOfArgs == 3) { else if (numberOfArgs == 3) {
@@ -1547,15 +1547,15 @@ int handleReportCalendar (std::string &outs)
else { else {
// task cal 8 2010 // task cal 8 2010
monthsToDisplay = monthsPerLine; monthsToDisplay = monthsPerLine;
mFrom = atoi( context.args[1].data()); mFrom = atoi (context.args[1].c_str ());
yFrom = atoi( context.args[2].data()); yFrom = atoi (context.args[2].c_str ());
} }
} }
else if (numberOfArgs == 4) { else if (numberOfArgs == 4) {
// task cal 8 2010 y // task cal 8 2010 y
monthsToDisplay = 12; monthsToDisplay = 12;
mFrom = atoi( context.args[1].data()); mFrom = atoi (context.args[1].c_str ());
yFrom = atoi( context.args[2].data()); yFrom = atoi (context.args[2].c_str ());
} }
int countDueDates = 0; int countDueDates = 0;
@@ -1728,7 +1728,7 @@ int handleReportStats (std::string &outs)
dataSize += undo.size (); dataSize += undo.size ();
std::vector <std::string> undoTxns; std::vector <std::string> undoTxns;
slurp (undo.data, undoTxns, false); slurp (undo, undoTxns, false);
int undoCount = 0; int undoCount = 0;
foreach (tx, undoTxns) foreach (tx, undoTxns)
if (tx->substr (0, 3) == "---") if (tx->substr (0, 3) == "---")

View File

@@ -33,7 +33,7 @@ Context context;
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (20); UnitTest t (21);
// Directory (const File&); // Directory (const File&);
// Directory (const Path&); // Directory (const Path&);
@@ -55,6 +55,9 @@ int main (int argc, char** argv)
Directory d5 = d4; Directory d5 = d4;
t.is (d5.data, "/tmp/test_directory", "Directory::operator="); t.is (d5.data, "/tmp/test_directory", "Directory::operator=");
// operator (std::string) const;
t.is ((std::string) d3, "/tmp", "Directory::operator (std::string) const");
// virtual bool create (); // virtual bool create ();
t.ok (d5.create (), "Directory::create /tmp/test_directory"); t.ok (d5.create (), "Directory::create /tmp/test_directory");
t.ok (d5.exists (), "Directory::exists /tmp/test_directory"); t.ok (d5.exists (), "Directory::exists /tmp/test_directory");

View File

@@ -33,7 +33,7 @@ Context context;
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (5); UnitTest t (6);
File::write ("/tmp/file.t.txt", "This is a test\n"); File::write ("/tmp/file.t.txt", "This is a test\n");
File f6 ("/tmp/file.t.txt"); File f6 ("/tmp/file.t.txt");
@@ -41,6 +41,9 @@ int main (int argc, char** argv)
t.ok (f6.mode () & S_IRUSR, "File::mode /tmp/file.t.txt good"); t.ok (f6.mode () & S_IRUSR, "File::mode /tmp/file.t.txt good");
t.ok (File::remove ("/tmp/file.t.txt"), "File::remove /tmp/file.t.txt good"); t.ok (File::remove ("/tmp/file.t.txt"), "File::remove /tmp/file.t.txt good");
// operator (std::string) const;
t.is ((std::string) f6, "/tmp/file.t.txt", "File::operator (std::string) const");
t.ok (File::create ("/tmp/file.t.create"), "File::create /tmp/file.t.create good"); t.ok (File::create ("/tmp/file.t.create"), "File::create /tmp/file.t.create good");
t.ok (File::remove ("/tmp/file.t.create"), "File::remove /tmp/file.t.create good"); t.ok (File::remove ("/tmp/file.t.create"), "File::remove /tmp/file.t.create good");

View File

@@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager. // task - a command line task list manager.
// //
// Copyright 2006 - 2009, Paul Beckingham. // Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved. // All rights reserved.
// //
// This program is free software; you can redistribute it and/or modify it under // This program is free software; you can redistribute it and/or modify it under
@@ -33,7 +33,7 @@ Context context;
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (31); UnitTest t (32);
// Path (); // Path ();
Path p0; Path p0;
@@ -54,6 +54,9 @@ int main (int argc, char** argv)
Path p3_copy (p3); Path p3_copy (p3);
t.is (p3.data, p3_copy.data, "Path::Path (Path&)"); t.is (p3.data, p3_copy.data, "Path::Path (Path&)");
// operator (std::string) const;
t.is ((std::string) p3, "/tmp", "Path::operator (std::string) const");
// std::string name () const; // std::string name () const;
Path p4 ("/a/b/c/file.ext"); Path p4 ("/a/b/c/file.ext");
t.is (p4.name (), "file.ext", "/a/b/c/file.ext name is file.ext"); t.is (p4.name (), "file.ext", "/a/b/c/file.ext name is file.ext");