- 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.
This commit is contained in:
Paul Beckingham 2008-09-12 16:07:50 -04:00
parent e9a71b7db9
commit fb87039d8c
6 changed files with 71 additions and 3 deletions

View file

@ -16,3 +16,5 @@ With thanks to:
H. İbrahim Güngör H. İbrahim Güngör
Stas Antons Stas Antons
Vincent Fleuranceau Vincent Fleuranceau
T. Charles Yun

View file

@ -20,6 +20,9 @@ represents a feature release, and the Z represents a patch.
the new "default.project" and "default.priority" configuration variables the new "default.project" and "default.priority" configuration variables
(thanks to Vincent Fleuranceau) (thanks to Vincent Fleuranceau)
+ Task supports improved word-wrapping to the terminal width + 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, + Bug: Now properly supports relative dates in filters (task list due:eom,
task list due:tomorrow, task list due:23rd ...) task list due:tomorrow, task list due:23rd ...)

View file

@ -43,6 +43,25 @@
lists all these commands. lists all these commands.
</p> </p>
<p>
However, if the following configuration variable is specified:
</p>
<pre><code>default.command=list pri:H</code></pre>
<p>
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:
</p>
<pre><code>% task
[task list project:foo]
ID Project Pri Description
1 foo H Design the thing
2 foo Build the thing</code></pre>
<strong>% task projects</strong> <strong>% task projects</strong>
<p> <p>
This report generates a list of all the different projects that you This report generates a list of all the different projects that you

View file

@ -258,6 +258,34 @@
<dd> <dd>
Provides a default priority for the "task add ..." command. Provides a default priority for the "task add ..." command.
</dd> </dd>
<dt>default.command</dt>
<dd>
<p>
Provides a default command that is run every time task is
invoked with no arguments. For example, if set to:
</p>
<pre><code>default.command=list project:foo</code></pre>
<p>
Then task will run the "list project:foo" command if no
command is specified. This means that by merely typing:
</p>
<pre><code>% task
[task list project:foo]
ID Project Pri Description
1 foo H Design the thing
2 foo Build the thing</code></pre>
<p>
Note that the value of this variable is simply the command
line that you would ordinarily type, but without the
preceding "task" program name.
</p>
</dd>
</div> </div>
<br /> <br />

View file

@ -104,6 +104,9 @@
the new "default.project" and "default.priority" configuration variables the new "default.project" and "default.priority" configuration variables
(thanks to Vincent Fleuranceau). (thanks to Vincent Fleuranceau).
<li>Task supports improved word-wrapping to the terminal width. <li>Task supports improved word-wrapping to the terminal width.
<li>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.
<li>Fixed bug so that relative dates in filters (task list due:eom, <li>Fixed bug so that relative dates in filters (task list due:eom,
task list due:tomorrow, task list due:23rd ...) are now properly task list due:tomorrow, task list due:23rd ...) are now properly
supported. supported.

View file

@ -299,10 +299,23 @@ int main (int argc, char** argv)
if (conf.get ("command.logging") == "on") if (conf.get ("command.logging") == "on")
tdb.logCommand (argc, argv); 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 <std::string> args; std::vector <std::string> args;
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) for (int i = 1; i < argc; ++i)
args.push_back (argv[i]); args.push_back (argv[i]);
}
std::string command; std::string command;
T task; T task;
parse (args, command, task, conf); parse (args, command, task, conf);