Review: Added framework

- Added 'review' command, which does nothing.
- Removed 'context' command, which now passes to Taskwarrior.
- Removed 'leave' command.
- Removed 'clear' command.
This commit is contained in:
Paul Beckingham 2015-05-23 22:42:03 -04:00
parent d485f9440a
commit 7f712d0926
4 changed files with 83 additions and 89 deletions

View file

@ -45,18 +45,15 @@
// tasksh commands.
int cmdHelp (const std::vector <std::string>&);
int cmdDiagnostics (const std::vector <std::string>&);
int cmdContext (const std::vector <std::string>&, std::vector <std::string>&);
int cmdClear (std::vector <std::string>&);
int cmdLeave (std::vector <std::string>&);
std::string composePrompt (std::vector <std::string>&);
std::string composeContexts (std::vector <std::string>&, bool pretty = false);
int cmdReview (const std::vector <std::string>&);
std::string promptCompose ();
std::string findTaskwarrior ();
////////////////////////////////////////////////////////////////////////////////
static int commandLoop (std::vector <std::string>& contexts)
static int commandLoop ()
{
// Compose the prompt.
std::string prompt = composePrompt (contexts);
std::string prompt = promptCompose ();
// Display prompt, get input.
#ifdef HAVE_READLINE
@ -90,18 +87,16 @@ static int commandLoop (std::vector <std::string>& contexts)
std::vector <std::string> args;
split (args, command, ' ');
// Dispatch command
// Dispatch command.
if (closeEnough ("exit", args[0], 3)) status = -1;
else if (closeEnough ("quit", args[0], 3)) status = -1;
else if (closeEnough ("help", args[0], 3)) status = cmdHelp (args );
else if (closeEnough ("diagnostics", args[0], 3)) status = cmdDiagnostics (args );
else if (closeEnough ("context", args[0], 3)) status = cmdContext (args, contexts);
else if (closeEnough ("clear", args[0], 3)) status = cmdClear ( contexts);
else if (closeEnough ("leave", args[0], 3)) status = cmdLeave ( contexts);
else if (closeEnough ("help", args[0], 3)) status = cmdHelp (args);
else if (closeEnough ("diagnostics", args[0], 3)) status = cmdDiagnostics (args);
else if (closeEnough ("review", args[0], 3)) status = cmdReview (args);
else if (command != "")
{
command = "task " + composeContexts (contexts) + command;
std::cout << "[task " << command << "]\n";
command = "task " + command;
std::cout << "[" << command << "]\n";
system (command.c_str ());
// Deliberately ignoreѕ taskwarrior exit status, otherwise empty filters
@ -126,8 +121,7 @@ int main (int argc, const char** argv)
{
try
{
std::vector <std::string> contexts;
while ((status = commandLoop (contexts)) == 0)
while ((status = commandLoop ()) == 0)
;
}