Refactoring
- Obsoleted Cmd object. - Removed Context::dispatch, renamed dispatch2 --> dispatch. - Commented out import and custom report functionality that depends on Cmd. This should be about as broken as taskwarrior gets. It's all uphill from here.
This commit is contained in:
@@ -257,6 +257,18 @@ bool Arguments::extract_command (
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO
|
||||||
|
void Arguments::extract_filter ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO
|
||||||
|
void Arguments::extract_modifications ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// A sequence can be:
|
// A sequence can be:
|
||||||
//
|
//
|
||||||
@@ -362,12 +374,6 @@ void Arguments::extract_sequence (std::vector <int>& sequence)
|
|||||||
this->erase (this->begin () + kill[k]);
|
this->erase (this->begin () + kill[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TODO
|
|
||||||
void Arguments::extract_nv ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TODO
|
// TODO
|
||||||
void Arguments::extract_uuids (std::vector <std::string>& uuids)
|
void Arguments::extract_uuids (std::vector <std::string>& uuids)
|
||||||
@@ -378,19 +384,31 @@ void Arguments::extract_uuids (std::vector <std::string>& uuids)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TODO
|
// TODO
|
||||||
void Arguments::extract_filter ()
|
void Arguments::extract_attrs ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TODO
|
// TODO
|
||||||
void Arguments::extract_modifications ()
|
void Arguments::extract_words ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TODO
|
// TODO
|
||||||
void Arguments::extract_text ()
|
void Arguments::extract_tags ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO
|
||||||
|
void Arguments::extract_pattern ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO
|
||||||
|
void Arguments::extract_subst ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,12 +49,16 @@ public:
|
|||||||
std::string combine ();
|
std::string combine ();
|
||||||
|
|
||||||
bool extract_command (const std::vector <std::string>&, std::string&);
|
bool extract_command (const std::vector <std::string>&, std::string&);
|
||||||
void extract_sequence (std::vector <int>&);
|
|
||||||
void extract_nv ();
|
|
||||||
void extract_uuids (std::vector <std::string>&);
|
|
||||||
void extract_filter ();
|
void extract_filter ();
|
||||||
void extract_modifications ();
|
void extract_modifications ();
|
||||||
void extract_text ();
|
|
||||||
|
void extract_sequence (std::vector <int>&);
|
||||||
|
void extract_uuids (std::vector <std::string>&);
|
||||||
|
void extract_attrs ();
|
||||||
|
void extract_words ();
|
||||||
|
void extract_tags ();
|
||||||
|
void extract_pattern ();
|
||||||
|
void extract_subst ();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -349,12 +349,13 @@ bool Att::validNameValue (
|
|||||||
|
|
||||||
// Some attributes are intended to be private, unless the command is read-
|
// Some attributes are intended to be private, unless the command is read-
|
||||||
// only, in which cased these are perfectly valid elements of a filter.
|
// only, in which cased these are perfectly valid elements of a filter.
|
||||||
|
/*
|
||||||
if (context.cmd.isWriteCommand () &&
|
if (context.cmd.isWriteCommand () &&
|
||||||
!validModifiableName (name))
|
!validModifiableName (name))
|
||||||
throw std::string ("\"") +
|
throw std::string ("\"") +
|
||||||
name +
|
name +
|
||||||
"\" is not an attribute you may modify directly.";
|
"\" is not an attribute you may modify directly.";
|
||||||
|
*/
|
||||||
else if (name == "priority")
|
else if (name == "priority")
|
||||||
{
|
{
|
||||||
if (value != "")
|
if (value != "")
|
||||||
@@ -371,7 +372,7 @@ bool Att::validNameValue (
|
|||||||
|
|
||||||
else if (name == "description")
|
else if (name == "description")
|
||||||
{
|
{
|
||||||
if (context.cmd.isWriteCommand ())
|
// if (context.cmd.isWriteCommand ())
|
||||||
{
|
{
|
||||||
if (value == "")
|
if (value == "")
|
||||||
throw std::string ("The '") + name + "' attribute must not be blank.";
|
throw std::string ("The '") + name + "' attribute must not be blank.";
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||||||
set (task_SRCS API.cpp API.h
|
set (task_SRCS API.cpp API.h
|
||||||
Arguments.cpp Arguments.h
|
Arguments.cpp Arguments.h
|
||||||
Att.cpp Att.h
|
Att.cpp Att.h
|
||||||
Cmd.cpp Cmd.h
|
|
||||||
Color.cpp Color.h
|
Color.cpp Color.h
|
||||||
Config.cpp Config.h
|
Config.cpp Config.h
|
||||||
Context.cpp Context.h
|
Context.cpp Context.h
|
||||||
|
|||||||
197
src/Cmd.cpp
197
src/Cmd.cpp
@@ -1,197 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// taskwarrior - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU General Public License as published by the Free Software
|
|
||||||
// Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
// version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License along with
|
|
||||||
// this program; if not, write to the
|
|
||||||
//
|
|
||||||
// Free Software Foundation, Inc.,
|
|
||||||
// 51 Franklin Street, Fifth Floor,
|
|
||||||
// Boston, MA
|
|
||||||
// 02110-1301
|
|
||||||
// USA
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <Cmd.h>
|
|
||||||
#include <Context.h>
|
|
||||||
#include <util.h>
|
|
||||||
#include <text.h>
|
|
||||||
#include <i18n.h>
|
|
||||||
#include <main.h>
|
|
||||||
|
|
||||||
extern Context context;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Cmd::Cmd ()
|
|
||||||
: command ("")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Cmd::Cmd (const std::string& input)
|
|
||||||
{
|
|
||||||
parse (input);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Cmd::~Cmd ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Determines whether the string represents a unique command name or custom
|
|
||||||
// report name.
|
|
||||||
//
|
|
||||||
// To be a valid command:
|
|
||||||
// 1. 'input' should autocomplete to one of 'commands'.
|
|
||||||
bool Cmd::valid (const std::string& input)
|
|
||||||
{
|
|
||||||
load ();
|
|
||||||
|
|
||||||
std::vector <std::string> matches;
|
|
||||||
autoComplete (lowerCase (input), commands, matches);
|
|
||||||
if (matches.size () == 1)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Determines whether the string represents a valid custom report name.
|
|
||||||
//
|
|
||||||
// To be a valid custom command:
|
|
||||||
// 1. 'input' should autocomplete to one of 'commands'.
|
|
||||||
// 2. the result, canonicalized, should autocomplete to one of
|
|
||||||
// 'customreports'.
|
|
||||||
bool Cmd::validCustom (const std::string& input)
|
|
||||||
{
|
|
||||||
load ();
|
|
||||||
|
|
||||||
std::vector <std::string> matches;
|
|
||||||
autoComplete (lowerCase (input), commands, matches);
|
|
||||||
if (matches.size () == 1)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
std::string canonical = context.canonicalize (matches[0]);
|
|
||||||
matches.clear ();
|
|
||||||
autoComplete (canonical, customReports, matches);
|
|
||||||
if (matches.size () == 1)
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// To be a valid custom command:
|
|
||||||
// 1. 'input' should autocomplete to one of 'commands'.
|
|
||||||
// 2. the result may then canonicalize to another command.
|
|
||||||
void Cmd::parse (const std::string& input)
|
|
||||||
{
|
|
||||||
load ();
|
|
||||||
|
|
||||||
std::vector <std::string> matches;
|
|
||||||
autoComplete (input, commands, matches);
|
|
||||||
if (1 == matches.size ())
|
|
||||||
/*command = context.canonicalize (matches[0])*/;
|
|
||||||
|
|
||||||
else if (0 == matches.size ())
|
|
||||||
command = "";
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string error = "Ambiguous command '" + input + "' - could be either of "; // TODO i18n
|
|
||||||
|
|
||||||
std::sort (matches.begin (), matches.end ());
|
|
||||||
std::string combined;
|
|
||||||
join (combined, ", ", matches);
|
|
||||||
throw error + combined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Cmd::load ()
|
|
||||||
{
|
|
||||||
if (commands.size () == 0)
|
|
||||||
{
|
|
||||||
// Now load the custom reports.
|
|
||||||
std::vector <std::string> all;
|
|
||||||
context.config.all (all);
|
|
||||||
|
|
||||||
std::vector <std::string>::iterator i;
|
|
||||||
for (i = all.begin (); i != all.end (); ++i)
|
|
||||||
{
|
|
||||||
if (i->substr (0, 7) == "report.")
|
|
||||||
{
|
|
||||||
std::string report = i->substr (7);
|
|
||||||
std::string::size_type columns = report.find (".columns");
|
|
||||||
if (columns != std::string::npos)
|
|
||||||
{
|
|
||||||
report = report.substr (0, columns);
|
|
||||||
|
|
||||||
// Make sure a custom report does not clash with a built-in
|
|
||||||
// command.
|
|
||||||
if (std::find (commands.begin (), commands.end (), report) != commands.end ())
|
|
||||||
throw std::string ("Custom report '") + report +
|
|
||||||
"' conflicts with built-in task command.";
|
|
||||||
|
|
||||||
// A custom report is also a command.
|
|
||||||
customReports.push_back (report);
|
|
||||||
commands.push_back (report);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now load the aliases.
|
|
||||||
std::map <std::string, std::string>::iterator it;
|
|
||||||
for (it = context.aliases.begin (); it != context.aliases.end (); ++it)
|
|
||||||
commands.push_back (it->first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Cmd::allCustomReports (std::vector <std::string>& all) const
|
|
||||||
{
|
|
||||||
all = customReports;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Cmd::allCommands (std::vector <std::string>& all) const
|
|
||||||
{
|
|
||||||
all.clear ();
|
|
||||||
std::vector <std::string>::const_iterator c;
|
|
||||||
for (c = commands.begin (); c != commands.end (); ++c)
|
|
||||||
if (c->substr (0, 1) != "_")
|
|
||||||
all.push_back (*c);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Commands that do not directly modify the data files.
|
|
||||||
bool Cmd::isReadOnlyCommand ()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Commands that directly modify the data files.
|
|
||||||
bool Cmd::isWriteCommand ()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
65
src/Cmd.h
65
src/Cmd.h
@@ -1,65 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// taskwarrior - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU General Public License as published by the Free Software
|
|
||||||
// Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
// version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License along with
|
|
||||||
// this program; if not, write to the
|
|
||||||
//
|
|
||||||
// Free Software Foundation, Inc.,
|
|
||||||
// 51 Franklin Street, Fifth Floor,
|
|
||||||
// Boston, MA
|
|
||||||
// 02110-1301
|
|
||||||
// USA
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef INCLUDED_CMD
|
|
||||||
#define INCLUDED_CMD
|
|
||||||
#define L10N // Localization complete.
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class Cmd
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Cmd (); // Default constructor
|
|
||||||
Cmd (const std::string&); // Default constructor
|
|
||||||
~Cmd (); // Destructor
|
|
||||||
|
|
||||||
Cmd (const Cmd&);
|
|
||||||
Cmd& operator= (const Cmd&);
|
|
||||||
|
|
||||||
bool valid (const std::string&);
|
|
||||||
bool validCustom (const std::string&);
|
|
||||||
void parse (const std::string&);
|
|
||||||
void allCustomReports (std::vector <std::string>&) const;
|
|
||||||
void allCommands (std::vector <std::string>&) const;
|
|
||||||
|
|
||||||
bool isReadOnlyCommand ();
|
|
||||||
bool isWriteCommand ();
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::string command;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void load ();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector <std::string> commands;
|
|
||||||
std::vector <std::string> customReports;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
@@ -58,7 +58,6 @@ Context::Context ()
|
|||||||
, commandLine ("")
|
, commandLine ("")
|
||||||
, file_override ("")
|
, file_override ("")
|
||||||
, var_overrides ("")
|
, var_overrides ("")
|
||||||
, cmd ()
|
|
||||||
, dom ()
|
, dom ()
|
||||||
, determine_color_use (true)
|
, determine_color_use (true)
|
||||||
, use_color (true)
|
, use_color (true)
|
||||||
@@ -110,13 +109,13 @@ void Context::initialize (int argc, const char** argv)
|
|||||||
// Create missing config file and data directory, if necessary.
|
// Create missing config file and data directory, if necessary.
|
||||||
createDefaultConfig ();
|
createDefaultConfig ();
|
||||||
|
|
||||||
// Apply rc overrides to Context::config, capturing raw args for later use.
|
|
||||||
args.apply_overrides (var_overrides);
|
|
||||||
|
|
||||||
// Handle Aliases.
|
// Handle Aliases.
|
||||||
loadAliases ();
|
loadAliases ();
|
||||||
args.resolve_aliases ();
|
args.resolve_aliases ();
|
||||||
|
|
||||||
|
// Apply rc overrides to Context::config, capturing raw args for later use.
|
||||||
|
args.apply_overrides (var_overrides);
|
||||||
|
|
||||||
// Combine command line into one string.
|
// Combine command line into one string.
|
||||||
commandLine = args.combine ();
|
commandLine = args.combine ();
|
||||||
|
|
||||||
@@ -155,10 +154,7 @@ int Context::run ()
|
|||||||
std::string output;
|
std::string output;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
parse (); // Parse command line. TODO Obsolete
|
rc = dispatch (output);
|
||||||
rc = dispatch2 (output); // Dispatch to new command handlers.
|
|
||||||
if (rc)
|
|
||||||
rc = dispatch (output); // Dispatch to old command handlers.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (const std::string& error)
|
catch (const std::string& error)
|
||||||
@@ -207,9 +203,9 @@ int Context::run ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Locate and dispatch to the command whose keyword matches via autoComplete
|
// Locate and dispatch to the command whose keyword matches via autoComplete
|
||||||
// with the earliest argument.
|
// with the earliest argument.
|
||||||
int Context::dispatch2 (std::string &out)
|
int Context::dispatch (std::string &out)
|
||||||
{
|
{
|
||||||
Timer t ("Context::dispatch2");
|
Timer t ("Context::dispatch");
|
||||||
|
|
||||||
updateXtermTitle ();
|
updateXtermTitle ();
|
||||||
|
|
||||||
@@ -235,34 +231,7 @@ int Context::dispatch2 (std::string &out)
|
|||||||
// TODO Need to invoke 'information' when a sequence/filter is present, but
|
// TODO Need to invoke 'information' when a sequence/filter is present, but
|
||||||
// no command is specified.
|
// no command is specified.
|
||||||
|
|
||||||
// TODO When ::dispatch is eliminated, show usage on unrecognized command.
|
return commands["help"]->execute (commandLine, out);
|
||||||
// commands["help"]->execute (commandLine, out);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
int Context::dispatch (std::string &out)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
Timer t ("Context::dispatch");
|
|
||||||
|
|
||||||
// TODO Chain-of-command pattern dispatch.
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// Commands that display IDs and therefore need TDB::gc first.
|
|
||||||
// ...
|
|
||||||
|
|
||||||
rc = commands["help"]->execute (commandLine, out);
|
|
||||||
|
|
||||||
// Only update the shadow file if such an update was not suppressed (shadow),
|
|
||||||
if ((cmd.isWriteCommand () ||
|
|
||||||
(cmd.command == "" && sequence.size ())) &&
|
|
||||||
!inShadow)
|
|
||||||
shadow ();
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -359,7 +328,7 @@ void Context::shadow ()
|
|||||||
config.set ("detection", "off");
|
config.set ("detection", "off");
|
||||||
config.set ("color", "off");
|
config.set ("color", "off");
|
||||||
|
|
||||||
parse ();
|
// parse ();
|
||||||
std::string result;
|
std::string result;
|
||||||
(void)dispatch (result);
|
(void)dispatch (result);
|
||||||
std::ofstream out (shadowFile.data.c_str ());
|
std::ofstream out (shadowFile.data.c_str ());
|
||||||
@@ -390,7 +359,7 @@ void Context::disallowModification () const
|
|||||||
tagAdditions.size () ||
|
tagAdditions.size () ||
|
||||||
tagRemovals.size ())
|
tagRemovals.size ())
|
||||||
throw std::string ("The '")
|
throw std::string ("The '")
|
||||||
+ cmd.command
|
// + cmd.command
|
||||||
+ "' command does not allow further modification of a task.";
|
+ "' command does not allow further modification of a task.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,12 +416,15 @@ void Context::loadAliases ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/*
|
||||||
void Context::parse ()
|
void Context::parse ()
|
||||||
{
|
{
|
||||||
parse (args, cmd, task, sequence, subst, filter);
|
parse (args, cmd, task, sequence, subst, filter);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/*
|
||||||
void Context::parse (
|
void Context::parse (
|
||||||
std::vector <std::string>& parseArgs,
|
std::vector <std::string>& parseArgs,
|
||||||
Cmd& parseCmd,
|
Cmd& parseCmd,
|
||||||
@@ -697,6 +669,7 @@ void Context::parse (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Context::decomposeSortField (
|
void Context::decomposeSortField (
|
||||||
@@ -742,7 +715,7 @@ void Context::clear ()
|
|||||||
args.clear ();
|
args.clear ();
|
||||||
file_override = "";
|
file_override = "";
|
||||||
var_overrides = "";
|
var_overrides = "";
|
||||||
cmd.command = ""; // TODO Obsolete
|
// cmd.command = ""; // TODO Obsolete
|
||||||
tagAdditions.clear ();
|
tagAdditions.clear ();
|
||||||
tagRemovals.clear ();
|
tagRemovals.clear ();
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <Sequence.h>
|
#include <Sequence.h>
|
||||||
#include <Subst.h>
|
#include <Subst.h>
|
||||||
#include <Cmd.h>
|
|
||||||
#include <Task.h>
|
#include <Task.h>
|
||||||
#include <TDB.h>
|
#include <TDB.h>
|
||||||
#include <TDB2.h>
|
#include <TDB2.h>
|
||||||
@@ -56,7 +55,6 @@ public:
|
|||||||
|
|
||||||
void initialize (int, const char**); // all startup
|
void initialize (int, const char**); // all startup
|
||||||
int run ();
|
int run ();
|
||||||
int dispatch2 (std::string&); // command handler dispatch
|
|
||||||
int dispatch (std::string&); // command handler dispatch
|
int dispatch (std::string&); // command handler dispatch
|
||||||
void shadow (); // shadow file update
|
void shadow (); // shadow file update
|
||||||
|
|
||||||
@@ -71,8 +69,10 @@ public:
|
|||||||
void debug (const std::string&); // Debug message sink
|
void debug (const std::string&); // Debug message sink
|
||||||
void clearMessages ();
|
void clearMessages ();
|
||||||
|
|
||||||
|
/*
|
||||||
void parse ();
|
void parse ();
|
||||||
void parse (std::vector <std::string>&, Cmd&, Task&, Sequence&, Subst&, Filter&);
|
void parse (std::vector <std::string>&, Cmd&, Task&, Sequence&, Subst&, Filter&);
|
||||||
|
*/
|
||||||
void clear ();
|
void clear ();
|
||||||
|
|
||||||
void disallowModification () const;
|
void disallowModification () const;
|
||||||
@@ -105,7 +105,6 @@ public:
|
|||||||
std::string commandLine;
|
std::string commandLine;
|
||||||
std::string file_override;
|
std::string file_override;
|
||||||
std::string var_overrides;
|
std::string var_overrides;
|
||||||
Cmd cmd; // TODO Obsolete
|
|
||||||
std::map <std::string, std::string> aliases;
|
std::map <std::string, std::string> aliases;
|
||||||
std::vector <std::string> tagAdditions;
|
std::vector <std::string> tagAdditions;
|
||||||
std::vector <std::string> tagRemovals;
|
std::vector <std::string> tagRemovals;
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ int CmdCustom::execute (const std::string&, std::string& output)
|
|||||||
split (filterArgs, reportFilter, ' ');
|
split (filterArgs, reportFilter, ' ');
|
||||||
// context.applyOverrides (filterArgs, filteredArgs);
|
// context.applyOverrides (filterArgs, filteredArgs);
|
||||||
|
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
Cmd cmd (_keyword);
|
Cmd cmd (_keyword);
|
||||||
Task task;
|
Task task;
|
||||||
@@ -105,6 +106,7 @@ int CmdCustom::execute (const std::string&, std::string& output)
|
|||||||
for (att = filter.begin (); att != filter.end (); ++att)
|
for (att = filter.begin (); att != filter.end (); ++att)
|
||||||
context.filter.push_back (*att);
|
context.filter.push_back (*att);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
|
|||||||
@@ -693,15 +693,16 @@ std::string CmdImport::taskCmdLine (const std::vector <std::string>& lines)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
context.args.clear ();
|
context.args.clear ();
|
||||||
split (context.args, std::string ("add ") + line, ' ');
|
split (context.args, std::string ("add ") + line, ' ');
|
||||||
|
|
||||||
context.task.clear ();
|
context.task.clear ();
|
||||||
context.cmd.command = "";
|
context.cmd.command = "";
|
||||||
context.parse ();
|
context.parse ();
|
||||||
// (void)handleAdd (unused);
|
|
||||||
context.commands["add"]->execute (unused, unused);
|
context.commands["add"]->execute (unused, unused);
|
||||||
context.clearMessages ();
|
context.clearMessages ();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (...)
|
catch (...)
|
||||||
@@ -801,10 +802,12 @@ std::string CmdImport::todoSh_2_0 (const std::vector <std::string>& lines)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
context.task.clear ();
|
context.task.clear ();
|
||||||
context.cmd.command = "";
|
context.cmd.command = "";
|
||||||
context.parse ();
|
context.parse ();
|
||||||
decorateTask (context.task);
|
decorateTask (context.task);
|
||||||
|
*/
|
||||||
|
|
||||||
// Override the Task::pending that decorateTask applies.
|
// Override the Task::pending that decorateTask applies.
|
||||||
if (!isPending)
|
if (!isPending)
|
||||||
@@ -882,10 +885,12 @@ std::string CmdImport::text (const std::vector <std::string>& lines)
|
|||||||
context.args.clear ();
|
context.args.clear ();
|
||||||
split (context.args, std::string ("add ") + line, ' ');
|
split (context.args, std::string ("add ") + line, ' ');
|
||||||
|
|
||||||
|
/*
|
||||||
context.task.clear ();
|
context.task.clear ();
|
||||||
context.cmd.command = "";
|
context.cmd.command = "";
|
||||||
context.parse ();
|
context.parse ();
|
||||||
decorateTask (context.task);
|
decorateTask (context.task);
|
||||||
|
*/
|
||||||
|
|
||||||
context.tdb.add (context.task);
|
context.tdb.add (context.task);
|
||||||
context.clearMessages ();
|
context.clearMessages ();
|
||||||
|
|||||||
Reference in New Issue
Block a user