diff --git a/AUTHORS b/AUTHORS index a90a432e7..90e803dcb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,3 +16,5 @@ With thanks to: H. İbrahim Güngör Stas Antons Vincent Fleuranceau + T. Charles Yun + diff --git a/ChangeLog b/ChangeLog index 2b73ee2a7..78b5b5996 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,9 @@ represents a feature release, and the Z represents a patch. the new "default.project" and "default.priority" configuration variables (thanks to Vincent Fleuranceau) + Task supports improved word-wrapping to the terminal width + + Task now supports "default.command" configuration variable (for example + it could contain "list due:tomorrow") that is the command that is run + whenever task is invoked with no arguments. + Bug: Now properly supports relative dates in filters (task list due:eom, task list due:tomorrow, task list due:23rd ...) diff --git a/html/advanced.html b/html/advanced.html index feed82b65..3208f2671 100644 --- a/html/advanced.html +++ b/html/advanced.html @@ -43,6 +43,25 @@ lists all these commands.

+

+ However, if the following configuration variable is specified: +

+ +
default.command=list pri:H
+ +

+ Then this command will be run whenever task is run without arguments. + This means that your most common task command can be run simply + with the command: +

+ +
% task
+[task list project:foo]
+
+ID Project Pri Description
+ 1 foo     H   Design the thing
+ 2 foo         Build the thing
+ % task projects

This report generates a list of all the different projects that you diff --git a/html/config.html b/html/config.html index c579838f5..251766af1 100644 --- a/html/config.html +++ b/html/config.html @@ -258,6 +258,34 @@

Provides a default priority for the "task add ..." command.
+ +
default.command
+
+

+ Provides a default command that is run every time task is + invoked with no arguments. For example, if set to: +

+ +
default.command=list project:foo
+ +

+ Then task will run the "list project:foo" command if no + command is specified. This means that by merely typing: +

+ +
% task
+[task list project:foo]
+
+ID Project Pri Description
+ 1 foo     H   Design the thing
+ 2 foo         Build the thing
+ +

+ Note that the value of this variable is simply the command + line that you would ordinarily type, but without the + preceding "task" program name. +

+

diff --git a/html/task.html b/html/task.html index feca286da..6ada83b3c 100644 --- a/html/task.html +++ b/html/task.html @@ -104,6 +104,9 @@ the new "default.project" and "default.priority" configuration variables (thanks to Vincent Fleuranceau).
  • Task supports improved word-wrapping to the terminal width. +
  • Task now supports "default.command" configuration variable (for example + it could contain "list due:tomorrow") which is the command that is run + whenever task is invoked with no arguments.
  • Fixed bug so that relative dates in filters (task list due:eom, task list due:tomorrow, task list due:23rd ...) are now properly supported. diff --git a/src/task.cpp b/src/task.cpp index cc192e18e..9fbcf84f7 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -299,10 +299,23 @@ int main (int argc, char** argv) if (conf.get ("command.logging") == "on") tdb.logCommand (argc, argv); - // Parse the command line. + // If argc == 1 and the default.command configuration variable is set, + // then use that, otherwise stick with argc/argv. std::vector args; - for (int i = 1; i < argc; ++i) - args.push_back (argv[i]); + std::string defaultCommand = conf.get ("default.command"); + if (argc == 1 && defaultCommand != "") + { + // Stuff the command line. + split (args, defaultCommand, ' '); + std::cout << "[task " << defaultCommand << "]" << std::endl; + } + else + { + // Parse the command line. + for (int i = 1; i < argc; ++i) + args.push_back (argv[i]); + } + std::string command; T task; parse (args, command, task, conf);