diff --git a/src/Arguments.cpp b/src/Arguments.cpp index 1028156cf..883f833bc 100644 --- a/src/Arguments.cpp +++ b/src/Arguments.cpp @@ -26,10 +26,13 @@ //////////////////////////////////////////////////////////////////////////////// #include +#include +#include #include #include #include #include +#include #include #include #include @@ -47,17 +50,29 @@ Arguments::~Arguments () } //////////////////////////////////////////////////////////////////////////////// +// Add a pair for every argument, with a category of "". void Arguments::capture (int argc, const char** argv) { for (int i = 0; i < argc; ++i) - if (i > 0) - this->push_back (argv[i]); + this->push_back (std::make_pair (argv[i], (i == 0 ? "program" : ""))); + + categorize (); } //////////////////////////////////////////////////////////////////////////////// +// Add a pair with a category of "". +void Arguments::capture (const std::string& arg) +{ + this->push_back (std::make_pair (arg, "")); + categorize (); +} + +//////////////////////////////////////////////////////////////////////////////// +// Add a pair for every word from std::cin, with a category of "". void Arguments::append_stdin () { - // Capture any stdin args. + // Use 'select' to determine whether there is any std::cin content buffered + // before trying to read it, to prevent blocking. struct timeval tv; fd_set fds; tv.tv_sec = 0; @@ -70,12 +85,94 @@ void Arguments::append_stdin () std::string arg; while (std::cin >> arg) { + // It the terminator token is found, stop reading. if (arg == "--") break; - this->push_back (arg); + this->push_back (std::make_pair (arg, "")); } } + + categorize (); +} + +//////////////////////////////////////////////////////////////////////////////// +// Scan all the arguments, and assign a category. +void Arguments::categorize () +{ + bool terminated = false; + + // Generate a vector of command keywords against which autoComplete can run. + std::vector keywords; + std::map ::iterator k; + for (k = context.commands.begin (); k != context.commands.end (); ++k) + keywords.push_back (k->first); + + // First scan for a command. + std::vector >::iterator arg; + for (arg = this->begin (); arg != this->end (); ++arg) + { + if (arg->first == "--") + break; + + std::vector matches; + if (autoComplete (arg->first, keywords, matches) == 1) + { + if (arg->first != matches[0]) + context.debug ("Arguments::categorize keyword '" + arg->first + "' --> '" + matches[0] + "'"); + else + context.debug ("Arguments::categorize keyword '" + arg->first + "'"); + + // Not only categorize the command, but overwrite the original command + // the fule name. + arg->first = matches[0]; + arg->second = "command"; + + // Only the first match is a command. + break; + } + } + + // Now categorize every uncategorized argument. + for (arg = this->begin (); arg != this->end (); ++arg) + { + if (!terminated) + { + // Nothing after -- is to be interpreted in any way. + if (arg->first == "--") + { + terminated = true; + arg->second = "terminator"; + } + +// // Only categorize uncategorized args. +// else if (arg->second == "") + else + { + // rc: + if (arg->first.substr (0, 3) == "rc:") + arg->second = "rc"; + + // rc.[:=] + else if (arg->first.substr (0, 3) == "rc.") + arg->second = "override"; + + // TODO Sequence + // TODO UUID + // TODO +tag + // TODO -tag + // TODO subst + // TODO attr + + else if (arg->second == "") + arg->second = "word"; + } + } + + // All post-termination arguments are simply words. + else + arg->second = "word"; + } } //////////////////////////////////////////////////////////////////////////////// @@ -85,17 +182,13 @@ void Arguments::rc_override ( std::string& override) { // Is there an override for rc:? - std::vector ::iterator arg; + std::vector >::iterator arg; for (arg = this->begin (); arg != this->end (); ++arg) { - // Nothing after -- is to be interpreted in any way. - if (*arg == "--") - break; - - else if (arg->substr (0, 3) == "rc:") + if (arg->second == "rc") { - override = *arg; - rc = File (arg->substr (3)); + override = arg->first; + rc = File (arg->first.substr (3)); home = rc; std::string::size_type last_slash = rc.data.rfind ("/"); @@ -104,9 +197,10 @@ void Arguments::rc_override ( else home = "."; - this->erase (arg); context.header ("Using alternate .taskrc file " + rc.data); // TODO i18n - break; // Must break - iterator is dead. + + // Keep scanning, because if there are multiple rc:file arguments, we + // want the last one to dominate. } } } @@ -119,17 +213,21 @@ void Arguments::get_data_location (std::string& data) data = location; // Are there any overrides for data.location? - std::vector ::iterator arg; + std::vector >::iterator arg; for (arg = this->begin (); arg != this->end (); ++arg) { - if (*arg == "--") - break; - else if (arg->substr (0, 16) == "rc.data.location" && - ((*arg)[16] == ':' || (*arg)[16] == '=')) + if (arg->second == "override") { - data = arg->substr (17); - context.header ("Using alternate data.location " + data); // TODO i18n + if (arg->first.substr (0, 16) == "rc.data.location" && + (arg->first[16] == ':' || arg->first[16] == '=')) + { + data = arg->first.substr (17); + context.header ("Using alternate data.location " + data); // TODO i18n + } } + + // Keep scanning, because if there are multiple rc:file arguments, we + // want the last one to dominate. } } @@ -138,22 +236,14 @@ void Arguments::get_data_location (std::string& data) // leaving only the plain args. void Arguments::apply_overrides (std::string& var_overrides) { - std::vector filtered; - bool foundTerminator = false; - - std::vector ::iterator arg; + std::vector >::iterator arg; for (arg = this->begin (); arg != this->end (); ++arg) { - if (*arg == "--") - { - foundTerminator = true; - filtered.push_back (*arg); - } - else if (!foundTerminator && arg->substr (0, 3) == "rc.") + if (arg->second == "override") { std::string name; std::string value; - Nibbler n (*arg); + Nibbler n (arg->first); if (n.getLiteral ("rc.") && // rc. n.getUntilOneOf (":=", name) && // xxx n.skipN (1)) // : @@ -161,22 +251,15 @@ void Arguments::apply_overrides (std::string& var_overrides) n.getUntilEOS (value); // Don't care if it's blank. context.config.set (name, value); - context.footnote ("Configuration override " + arg->substr (3)); + context.footnote ("Configuration override rc." + name + "=" + value); // Overrides are retained for potential use by the default command. - var_overrides += " " + *arg; + var_overrides += " " + arg->first; } else - context.footnote ("Problem with override: " + *arg); + context.footnote ("Problem with override: " + arg->first); } - else - filtered.push_back (*arg); } - - // Overwrite args with the filtered subset. - this->clear (); - for (arg = filtered.begin (); arg != filtered.end (); ++arg) - this->push_back (*arg); } //////////////////////////////////////////////////////////////////////////////// @@ -187,22 +270,22 @@ void Arguments::resolve_aliases () std::vector expanded; bool something = false; - std::vector ::iterator arg; + std::vector >::iterator arg; for (arg = this->begin (); arg != this->end (); ++arg) { std::map ::iterator match = - context.aliases.find (*arg); + context.aliases.find (arg->first); if (match != context.aliases.end ()) { context.debug (std::string ("Arguments::resolve_aliases '") - + *arg + + arg->first + "' --> '" - + context.aliases[*arg] + + context.aliases[arg->first] + "'"); std::vector words; - splitq (words, context.aliases[*arg], ' '); + splitq (words, context.aliases[arg->first], ' '); std::vector ::iterator word; for (word = words.begin (); word != words.end (); ++word) @@ -211,45 +294,59 @@ void Arguments::resolve_aliases () something = true; } else - expanded.push_back (*arg); + expanded.push_back (arg->first); } // Only overwrite if something happened. if (something) { this->clear (); - for (arg = expanded.begin (); arg != expanded.end (); ++arg) - this->push_back (*arg); + std::vector ::iterator e; + for (e = expanded.begin (); e != expanded.end (); ++e) + this->push_back (std::make_pair (*e, "")); + + // Must now re-categorize everything. + categorize (); } } +//////////////////////////////////////////////////////////////////////////////// +std::vector Arguments::list () +{ + std::vector all; + std::vector >::iterator i; + for (i = this->begin (); i != this->end (); ++i) + all.push_back (i->first); + + return all; +} + //////////////////////////////////////////////////////////////////////////////// std::string Arguments::combine () { std::string combined; - join (combined, " ", *(std::vector *)this); + + std::vector >::iterator i; + for (i = this->begin (); i != this->end (); ++i) + { + if (i != this->begin ()) + combined += " "; + + combined += i->first; + } + return combined; } //////////////////////////////////////////////////////////////////////////////// -// Given a vector of command keywords, scan all arguments and locate the first -// argument that matches a keyword. -bool Arguments::extract_command ( - const std::vector & keywords, - std::string& command) +bool Arguments::find_command (std::string& command) { - std::vector ::iterator arg; + std::vector >::iterator arg; for (arg = this->begin (); arg != this->end (); ++arg) { - std::vector matches; - if (autoComplete (*arg, keywords, matches) == 1) + if (arg->second == "command") { - if (*arg != matches[0]) - context.debug ("Arguments::extract_command keyword '" + *arg + "' --> '" + matches[0] + "'"); - else - context.debug ("Arguments::extract_command keyword '" + *arg + "'"); - - command = matches[0]; + command = arg->first; return true; } } @@ -257,24 +354,6 @@ bool Arguments::extract_command ( return false; } -//////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::remove_command (const std::string& command) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::extract_filter () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::extract_modifications () -{ -} - //////////////////////////////////////////////////////////////////////////////// // A sequence can be: // @@ -300,6 +379,7 @@ void Arguments::extract_modifications () // void Arguments::extract_sequence (std::vector & sequence) { +/* sequence.clear (); std::vector kill; @@ -378,44 +458,52 @@ void Arguments::extract_sequence (std::vector & sequence) // Now remove args in the kill list. for (unsigned int k = 0; k < kill.size (); ++k) this->erase (this->begin () + kill[k]); +*/ } //////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::extract_uuids (std::vector & uuids) +void Arguments::dump (const std::string& label) { - uuids.clear (); + // Set up a map of categories to colors. + std::map color_map; + color_map["program"] = Color ("white on blue"); + color_map["command"] = Color ("black on cyan"); + color_map["rc"] = Color ("bold white on red"); + color_map["override"] = Color ("white on red"); + color_map["none"] = Color ("white on gray3"); -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::extract_attrs () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::extract_words () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::extract_tags () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::extract_pattern () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO -void Arguments::extract_subst () -{ + Color color_debug (context.config.get ("color.debug")); + std::stringstream out; + out << color_debug.colorize (label) + << "\n"; + + ViewText view; + view.width (context.getWidth ()); + view.leftMargin (4); + for (unsigned int i = 0; i < this->size (); ++i) + view.add (Column::factory ("string", "")); + + view.addRow (); + view.addRow (); + + for (unsigned int i = 0; i < this->size (); ++i) + { + std::string arg = (*this)[i].first; + std::string category = (*this)[i].second; + + Color c; + if (color_map[category].nontrivial ()) + c = color_map[category]; + else + c = color_map["none"]; + + view.set (0, i, arg, c); + view.set (1, i, category, c); + } + + out << view.render (); + context.debug (out.str ()); + std::cout << out.str (); // TODO Remove } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Arguments.h b/src/Arguments.h index ec370c8e6..3b87d4b17 100644 --- a/src/Arguments.h +++ b/src/Arguments.h @@ -34,38 +34,40 @@ #define ARGUMENTS_SEQUENCE_MAX_RANGE 1000 -class Arguments : public std::vector +class Arguments : public std::vector > { public: Arguments (); ~Arguments (); void capture (int, const char**); + void capture (const std::string&); + void categorize (); + void append_stdin (); void rc_override (std::string&, File&, std::string&); void get_data_location (std::string&); void apply_overrides (std::string&); void resolve_aliases (); + + std::vector list (); std::string combine (); - bool extract_command (const std::vector &, std::string&); - void remove_command (const std::string&); - + bool find_command (std::string&); /* - void extract_read_only (command, filter); - void extract_write_commands (filter, command, mods); -*/ - void extract_filter (); void extract_modifications (); - +*/ void extract_sequence (std::vector &); +/* void extract_uuids (std::vector &); void extract_attrs (); void extract_words (); void extract_tags (); void extract_pattern (); void extract_subst (); +*/ + void dump (const std::string&); }; #endif diff --git a/src/Config.cpp b/src/Config.cpp index 6df851c50..f8a9d4fc4 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -36,10 +36,12 @@ #include #include #include +#include #include #include #include #include +#include //////////////////////////////////////////////////////////////////////////////// // This string is used in two ways: @@ -473,9 +475,10 @@ Config::Config (const std::string& file) // void Config::load (const std::string& file, int nest /* = 1 */) { + Timer timer ("Config::load (" + file + ")"); + if (nest > 10) - throw std::string ("Configuration file nested to more than 10 levels deep" - " - this has to be a mistake."); + throw std::string (STRING_CONFIG_OVERNEST); // First time in, load the default values. if (nest == 1) diff --git a/src/Context.cpp b/src/Context.cpp index df915d07a..67ed4cfc7 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -44,8 +44,7 @@ //////////////////////////////////////////////////////////////////////////////// Context::Context () -: program ("") -, rc_file () +: rc_file () , data_dir () , extension_dir () , config () @@ -55,7 +54,6 @@ Context::Context () , task () , tdb () , tdb2 () -, commandLine ("") , file_override ("") , var_overrides ("") , dom () @@ -63,7 +61,6 @@ Context::Context () , use_color (true) , verbosity_legacy (false) , inShadow (false) -, command ("") , terminal_width (0) , terminal_height (0) { @@ -81,7 +78,6 @@ void Context::initialize (int argc, const char** argv) // char** argv --> std::vector Context::args. // TODO Handle "cal" case here. - program = argv[0]; args.capture (argc, argv); // echo one two -- three | task zero --> task zero one two @@ -117,9 +113,6 @@ void Context::initialize (int argc, const char** argv) // Apply rc overrides to Context::config, capturing raw args for later use. args.apply_overrides (var_overrides); - // Combine command line into one string. - commandLine = args.combine (); - // Initialize the color rules, if necessary. if (color ()) initializeColorRules (); @@ -130,14 +123,6 @@ void Context::initialize (int argc, const char** argv) // TODO Instantiate extension command objects. // TODO Instantiate default command object. - // Create list of all command keywords. - std::vector keywords; - std::map ::iterator i; - for (i = commands.begin (); i != commands.end (); ++i) - keywords.push_back (i->first); - - args.extract_command (keywords, command); - // TODO Instantiate extension UDA objects. // TODO Instantiate extension format objects. @@ -160,6 +145,8 @@ void Context::initialize (int argc, const char** argv) //////////////////////////////////////////////////////////////////////////////// int Context::run () { + Timer timer ("Context::run"); + int rc; std::string output; try @@ -181,12 +168,16 @@ int Context::run () // Dump all debug messages, controlled by rc.debug. if (config.getBoolean ("debug")) + { foreach (d, debugMessages) if (color ()) std::cout << colorizeDebug (*d) << "\n"; else std::cout << *d << "\n"; + args.dump ("Argument categorization"); + } + // Dump all headers, controlled by 'header' verbosity token. if (verbose ("header")) foreach (h, headers) @@ -218,7 +209,8 @@ int Context::dispatch (std::string &out) Timer t ("Context::dispatch"); // Autocomplete args against keywords. - if (command != "") + std::string command; + if (args.find_command (command)) { updateXtermTitle (); @@ -228,13 +220,13 @@ int Context::dispatch (std::string &out) if (c->displays_id ()) tdb.gc (); - return c->execute (commandLine, out); + return c->execute (out); } // TODO Need to invoke 'information' when a sequence/filter is present, but // no command is specified. - return commands["help"]->execute (commandLine, out); + return commands["help"]->execute (out); } //////////////////////////////////////////////////////////////////////////////// @@ -265,6 +257,8 @@ bool Context::color () // No need to go through this again. determine_color_use = false; + + debug ("Context::color --> " + std::string (use_color ? "on" : "off")); } // Cached result. @@ -294,6 +288,7 @@ bool Context::verbose (const std::string& token) // TODO OBSOLETE void Context::shadow () { +/* // Determine if shadow file is enabled. File shadowFile (config.get ("shadow.file")); if (shadowFile.data != "") @@ -352,6 +347,7 @@ void Context::shadow () inShadow = false; } +*/ } //////////////////////////////////////////////////////////////////////////////// @@ -708,8 +704,6 @@ void Context::clear () task = Task (); tdb.clear (); // TODO Obsolete // tdb2.clear (); - program = ""; - commandLine = ""; args.clear (); file_override = ""; var_overrides = ""; @@ -834,8 +828,11 @@ void Context::updateXtermTitle () { if (config.getBoolean ("xterm.title")) { + std::string command; + args.find_command (command); + std::string title; - join (title, " ", args); + join (title, " ", args.list ()); std::cout << "]0;task " << command << " " << title << "" << std::endl; } } diff --git a/src/Context.h b/src/Context.h index c85a7f9a0..162977a32 100644 --- a/src/Context.h +++ b/src/Context.h @@ -102,7 +102,6 @@ public: Task task; // TODO Obsolete TDB tdb; // TODO Obsolete TDB2 tdb2; - std::string commandLine; // TODO Obsolete std::string file_override; std::string var_overrides; std::map aliases; @@ -123,7 +122,6 @@ public: bool inShadow; std::map commands; - std::string command; int terminal_width; int terminal_height; diff --git a/src/DOM.cpp b/src/DOM.cpp index 0be0c2bdc..38dfe9e53 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -78,12 +78,12 @@ const std::string DOM::get (const std::string& name) name.substr (0, 8) == "context.") { if (name == "context.program") - return context.program; + return context.args[0].first; else if (name == "context.args") { std::string combined; - join (combined, " ", context.args); + join (combined, " ", context.args.list ()); return combined; } else if (name == "context.width") diff --git a/src/commands/CmdAdd.cpp b/src/commands/CmdAdd.cpp index c659e2fd7..6fb99b9ac 100644 --- a/src/commands/CmdAdd.cpp +++ b/src/commands/CmdAdd.cpp @@ -46,7 +46,7 @@ CmdAdd::CmdAdd () } //////////////////////////////////////////////////////////////////////////////// -int CmdAdd::execute (const std::string&, std::string& output) +int CmdAdd::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdAdd.h b/src/commands/CmdAdd.h index 30bfb597b..ed9145fe7 100644 --- a/src/commands/CmdAdd.h +++ b/src/commands/CmdAdd.h @@ -35,7 +35,7 @@ class CmdAdd : public Command { public: CmdAdd (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdAnnotate.cpp b/src/commands/CmdAnnotate.cpp index 018f09353..558727bc2 100644 --- a/src/commands/CmdAnnotate.cpp +++ b/src/commands/CmdAnnotate.cpp @@ -44,7 +44,7 @@ CmdAnnotate::CmdAnnotate () } //////////////////////////////////////////////////////////////////////////////// -int CmdAnnotate::execute (const std::string&, std::string& output) +int CmdAnnotate::execute (std::string& output) { int rc = 0; diff --git a/src/commands/CmdAnnotate.h b/src/commands/CmdAnnotate.h index 8a820bba5..c2c6b648b 100644 --- a/src/commands/CmdAnnotate.h +++ b/src/commands/CmdAnnotate.h @@ -35,7 +35,7 @@ class CmdAnnotate : public Command { public: CmdAnnotate (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdAppend.cpp b/src/commands/CmdAppend.cpp index 9cb9ee6f7..53fb0ef0f 100644 --- a/src/commands/CmdAppend.cpp +++ b/src/commands/CmdAppend.cpp @@ -44,7 +44,7 @@ CmdAppend::CmdAppend () } //////////////////////////////////////////////////////////////////////////////// -int CmdAppend::execute (const std::string&, std::string& output) +int CmdAppend::execute (std::string& output) { if (!context.task.has ("description")) throw std::string ("Additional text must be provided."); diff --git a/src/commands/CmdAppend.h b/src/commands/CmdAppend.h index ec7ae7990..1bcdb485c 100644 --- a/src/commands/CmdAppend.h +++ b/src/commands/CmdAppend.h @@ -35,7 +35,7 @@ class CmdAppend : public Command { public: CmdAppend (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdBurndown.cpp b/src/commands/CmdBurndown.cpp index 906df9ca9..58c80617c 100644 --- a/src/commands/CmdBurndown.cpp +++ b/src/commands/CmdBurndown.cpp @@ -978,7 +978,7 @@ CmdBurndownMonthly::CmdBurndownMonthly () } //////////////////////////////////////////////////////////////////////////////// -int CmdBurndownMonthly::execute (const std::string&, std::string& output) +int CmdBurndownMonthly::execute (std::string& output) { int rc = 0; @@ -1031,7 +1031,7 @@ CmdBurndownWeekly::CmdBurndownWeekly () } //////////////////////////////////////////////////////////////////////////////// -int CmdBurndownWeekly::execute (const std::string&, std::string& output) +int CmdBurndownWeekly::execute (std::string& output) { int rc = 0; @@ -1084,7 +1084,7 @@ CmdBurndownDaily::CmdBurndownDaily () } //////////////////////////////////////////////////////////////////////////////// -int CmdBurndownDaily::execute (const std::string&, std::string& output) +int CmdBurndownDaily::execute (std::string& output) { int rc = 0; diff --git a/src/commands/CmdBurndown.h b/src/commands/CmdBurndown.h index f4eb56c70..ada663350 100644 --- a/src/commands/CmdBurndown.h +++ b/src/commands/CmdBurndown.h @@ -35,21 +35,21 @@ class CmdBurndownMonthly : public Command { public: CmdBurndownMonthly (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdBurndownWeekly : public Command { public: CmdBurndownWeekly (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdBurndownDaily : public Command { public: CmdBurndownDaily (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index b9971f3e7..1b416edb2 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -48,7 +48,7 @@ CmdCalendar::CmdCalendar () } //////////////////////////////////////////////////////////////////////////////// -int CmdCalendar::execute (const std::string&, std::string& output) +int CmdCalendar::execute (std::string& output) { int rc = 0; @@ -114,8 +114,9 @@ int CmdCalendar::execute (const std::string&, std::string& output) int argMonth = 0; int argYear = 0; bool argWholeYear = false; + std::vector args = context.args.list (); std::vector ::iterator arg; - for (arg = context.args.begin (); arg != context.args.end (); ++arg) + for (arg = args.begin (); arg != args.end (); ++arg) { // Some version of "calendar". if (autoComplete (lowerCase (*arg), commandNames, matches) == 1) @@ -353,7 +354,7 @@ int CmdCalendar::execute (const std::string&, std::string& output) context.sequence.clear (); std::string output; - context.commands[report]->execute (context.commandLine, output); + context.commands[report]->execute (output); out << output; } diff --git a/src/commands/CmdCalendar.h b/src/commands/CmdCalendar.h index 6936a8d23..27059d623 100644 --- a/src/commands/CmdCalendar.h +++ b/src/commands/CmdCalendar.h @@ -38,7 +38,7 @@ class CmdCalendar : public Command { public: CmdCalendar (); - int execute (const std::string&, std::string&); + int execute (std::string&); private: std::string renderMonths (int, int, const Date&, std::vector &, int); diff --git a/src/commands/CmdColor.cpp b/src/commands/CmdColor.cpp index 10cb94e32..9111eac0c 100644 --- a/src/commands/CmdColor.cpp +++ b/src/commands/CmdColor.cpp @@ -44,7 +44,7 @@ CmdColor::CmdColor () } //////////////////////////////////////////////////////////////////////////////// -int CmdColor::execute (const std::string&, std::string& output) +int CmdColor::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdColor.h b/src/commands/CmdColor.h index 81c0afb82..a08486472 100644 --- a/src/commands/CmdColor.h +++ b/src/commands/CmdColor.h @@ -35,7 +35,7 @@ class CmdColor : public Command { public: CmdColor (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdCommands.cpp b/src/commands/CmdCommands.cpp index 20c8ddf0e..109874cb7 100644 --- a/src/commands/CmdCommands.cpp +++ b/src/commands/CmdCommands.cpp @@ -45,7 +45,7 @@ CmdCompletionCommands::CmdCompletionCommands () } //////////////////////////////////////////////////////////////////////////////// -int CmdCompletionCommands::execute (const std::string&, std::string& output) +int CmdCompletionCommands::execute (std::string& output) { // Get a list of all commands. std::vector commands; @@ -81,7 +81,7 @@ CmdZshCommands::CmdZshCommands () } //////////////////////////////////////////////////////////////////////////////// -int CmdZshCommands::execute (const std::string&, std::string& output) +int CmdZshCommands::execute (std::string& output) { // Get a list of all commands. std::vector commands; diff --git a/src/commands/CmdCommands.h b/src/commands/CmdCommands.h index c9d804a9f..dec699eaf 100644 --- a/src/commands/CmdCommands.h +++ b/src/commands/CmdCommands.h @@ -35,14 +35,14 @@ class CmdCompletionCommands : public Command { public: CmdCompletionCommands (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdZshCommands : public Command { public: CmdZshCommands (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdConfig.cpp b/src/commands/CmdConfig.cpp index 8a4b7ffe6..6005be1c3 100644 --- a/src/commands/CmdConfig.cpp +++ b/src/commands/CmdConfig.cpp @@ -45,9 +45,12 @@ CmdConfig::CmdConfig () } //////////////////////////////////////////////////////////////////////////////// -int CmdConfig::execute (const std::string&, std::string& output) +int CmdConfig::execute (std::string& output) { int rc = 0; +/* + TODO Revise argument handling + std::stringstream out; // Obtain the arguments from the description. That way, things like '--' @@ -160,6 +163,7 @@ int CmdConfig::execute (const std::string&, std::string& output) } else throw std::string ("Specify the name of a config variable to modify."); +*/ return rc; } @@ -176,7 +180,7 @@ CmdCompletionConfig::CmdCompletionConfig () } //////////////////////////////////////////////////////////////////////////////// -int CmdCompletionConfig::execute (const std::string&, std::string& output) +int CmdCompletionConfig::execute (std::string& output) { std::vector configs; context.config.all (configs); diff --git a/src/commands/CmdConfig.h b/src/commands/CmdConfig.h index 75b027bf9..f2c8f1b14 100644 --- a/src/commands/CmdConfig.h +++ b/src/commands/CmdConfig.h @@ -35,14 +35,14 @@ class CmdConfig : public Command { public: CmdConfig (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdCompletionConfig : public Command { public: CmdCompletionConfig (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdCount.cpp b/src/commands/CmdCount.cpp index 7db6751d5..a5e34a6d2 100644 --- a/src/commands/CmdCount.cpp +++ b/src/commands/CmdCount.cpp @@ -43,7 +43,7 @@ CmdCount::CmdCount () } //////////////////////////////////////////////////////////////////////////////// -int CmdCount::execute (const std::string&, std::string& output) +int CmdCount::execute (std::string& output) { // Scan the pending tasks, applying any filter. std::vector tasks; diff --git a/src/commands/CmdCount.h b/src/commands/CmdCount.h index ffdef0bf6..04730d687 100644 --- a/src/commands/CmdCount.h +++ b/src/commands/CmdCount.h @@ -35,7 +35,7 @@ class CmdCount : public Command { public: CmdCount (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index 574f573f4..f78ac1749 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -51,7 +51,7 @@ CmdCustom::CmdCustom ( } //////////////////////////////////////////////////////////////////////////////// -int CmdCustom::execute (const std::string&, std::string& output) +int CmdCustom::execute (std::string& output) { int rc = 0; @@ -128,7 +128,6 @@ int CmdCustom::execute (const std::string&, std::string& output) //////////////////////////////////// // TODO Create the filter - context.args.remove_command (_keyword); //std::vector filter_args; //context.args.extract_filter (filter_args); diff --git a/src/commands/CmdCustom.h b/src/commands/CmdCustom.h index 84dd9978e..4171e8b32 100644 --- a/src/commands/CmdCustom.h +++ b/src/commands/CmdCustom.h @@ -35,7 +35,7 @@ class CmdCustom : public Command { public: CmdCustom (const std::string&, const std::string&, const std::string&); - int execute (const std::string&, std::string&); + int execute (std::string&); private: void validateReportColumns (std::vector &); diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index f3e18e8e6..8f132c2a5 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -45,7 +45,7 @@ CmdDelete::CmdDelete () } //////////////////////////////////////////////////////////////////////////////// -int CmdDelete::execute (const std::string&, std::string& output) +int CmdDelete::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdDelete.h b/src/commands/CmdDelete.h index 401d08ca5..7be8726b3 100644 --- a/src/commands/CmdDelete.h +++ b/src/commands/CmdDelete.h @@ -35,7 +35,7 @@ class CmdDelete : public Command { public: CmdDelete (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdDenotate.cpp b/src/commands/CmdDenotate.cpp index 0e48546cf..07bd7dc78 100644 --- a/src/commands/CmdDenotate.cpp +++ b/src/commands/CmdDenotate.cpp @@ -45,7 +45,7 @@ CmdDenotate::CmdDenotate () } //////////////////////////////////////////////////////////////////////////////// -int CmdDenotate::execute (const std::string&, std::string& output) +int CmdDenotate::execute (std::string& output) { int rc = 0; diff --git a/src/commands/CmdDenotate.h b/src/commands/CmdDenotate.h index 4a43d4ea5..1dc47a2f4 100644 --- a/src/commands/CmdDenotate.h +++ b/src/commands/CmdDenotate.h @@ -35,7 +35,7 @@ class CmdDenotate : public Command { public: CmdDenotate (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdDiagnostics.cpp b/src/commands/CmdDiagnostics.cpp index 280388562..d4e50a9b7 100644 --- a/src/commands/CmdDiagnostics.cpp +++ b/src/commands/CmdDiagnostics.cpp @@ -63,7 +63,7 @@ CmdDiagnostics::CmdDiagnostics () // // Although this will change over time, initially this command will answer the // kind of questions we always have to ask whenever something is wrong. -int CmdDiagnostics::execute (const std::string&, std::string& output) +int CmdDiagnostics::execute (std::string& output) { Color bold ("bold"); diff --git a/src/commands/CmdDiagnostics.h b/src/commands/CmdDiagnostics.h index 2df5b7c7a..b97123a57 100644 --- a/src/commands/CmdDiagnostics.h +++ b/src/commands/CmdDiagnostics.h @@ -35,7 +35,7 @@ class CmdDiagnostics : public Command { public: CmdDiagnostics (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdDone.cpp b/src/commands/CmdDone.cpp index df4ce9221..df999c846 100644 --- a/src/commands/CmdDone.cpp +++ b/src/commands/CmdDone.cpp @@ -44,7 +44,7 @@ CmdDone::CmdDone () } //////////////////////////////////////////////////////////////////////////////// -int CmdDone::execute (const std::string&, std::string& output) +int CmdDone::execute (std::string& output) { int rc = 0; int count = 0; diff --git a/src/commands/CmdDone.h b/src/commands/CmdDone.h index 7818bac1c..515c5ff10 100644 --- a/src/commands/CmdDone.h +++ b/src/commands/CmdDone.h @@ -35,7 +35,7 @@ class CmdDone : public Command { public: CmdDone (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdDuplicate.cpp b/src/commands/CmdDuplicate.cpp index 7e2b64186..b05539c94 100644 --- a/src/commands/CmdDuplicate.cpp +++ b/src/commands/CmdDuplicate.cpp @@ -45,7 +45,7 @@ CmdDuplicate::CmdDuplicate () } //////////////////////////////////////////////////////////////////////////////// -int CmdDuplicate::execute (const std::string&, std::string& output) +int CmdDuplicate::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdDuplicate.h b/src/commands/CmdDuplicate.h index 662a2855c..8bad2d288 100644 --- a/src/commands/CmdDuplicate.h +++ b/src/commands/CmdDuplicate.h @@ -35,7 +35,7 @@ class CmdDuplicate : public Command { public: CmdDuplicate (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index c2651488f..5b5f725aa 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -52,7 +52,7 @@ CmdEdit::CmdEdit () // Introducing the Silver Bullet. This feature is the catch-all fixative for // various other ills. This is like opening up the hood and going in with a // wrench. To be used sparingly. -int CmdEdit::execute (const std::string&, std::string& output) +int CmdEdit::execute (std::string& output) { int rc = 0; diff --git a/src/commands/CmdEdit.h b/src/commands/CmdEdit.h index 022066d0e..ed7003b0b 100644 --- a/src/commands/CmdEdit.h +++ b/src/commands/CmdEdit.h @@ -36,7 +36,7 @@ class CmdEdit : public Command { public: CmdEdit (); - int execute (const std::string&, std::string&); + int execute (std::string&); private: std::string findValue (const std::string&, const std::string&); diff --git a/src/commands/CmdExec.cpp b/src/commands/CmdExec.cpp index 505026960..5ee2e40ce 100644 --- a/src/commands/CmdExec.cpp +++ b/src/commands/CmdExec.cpp @@ -26,8 +26,11 @@ //////////////////////////////////////////////////////////////////////////////// #include +#include #include +extern Context context; + //////////////////////////////////////////////////////////////////////////////// CmdExec::CmdExec () { @@ -39,8 +42,17 @@ CmdExec::CmdExec () } //////////////////////////////////////////////////////////////////////////////// -int CmdExec::execute (const std::string& command_line, std::string&) +int CmdExec::execute (std::string& output) { + std::string command_line; + std::vector >::iterator arg; + for (arg = context.args.begin (); arg != context.args.end (); ++arg) + { + if (arg != context.args.begin () && + arg->first != "execute") + command_line += arg->first; + } + return system (command_line.c_str ()); } diff --git a/src/commands/CmdExec.h b/src/commands/CmdExec.h index f9161abcb..6227f476d 100644 --- a/src/commands/CmdExec.h +++ b/src/commands/CmdExec.h @@ -35,7 +35,7 @@ class CmdExec : public Command { public: CmdExec (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdHelp.cpp b/src/commands/CmdHelp.cpp index 439114f80..5d6108737 100644 --- a/src/commands/CmdHelp.cpp +++ b/src/commands/CmdHelp.cpp @@ -44,7 +44,7 @@ CmdHelp::CmdHelp () } //////////////////////////////////////////////////////////////////////////////// -int CmdHelp::execute (const std::string&, std::string& output) +int CmdHelp::execute (std::string& output) { ViewText view; view.width (context.getWidth ()); diff --git a/src/commands/CmdHelp.h b/src/commands/CmdHelp.h index 67d503b15..3033d772c 100644 --- a/src/commands/CmdHelp.h +++ b/src/commands/CmdHelp.h @@ -35,7 +35,7 @@ class CmdHelp : public Command { public: CmdHelp (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdHistory.cpp b/src/commands/CmdHistory.cpp index 27e50a01b..bfbfa9050 100644 --- a/src/commands/CmdHistory.cpp +++ b/src/commands/CmdHistory.cpp @@ -38,7 +38,6 @@ extern Context context; CmdHistoryMonthly::CmdHistoryMonthly () { _keyword = "history.monthly"; - _usage = "task execute "; _usage = "task history.monthly []"; _description = "Shows a report of task history, by month."; _read_only = true; @@ -46,7 +45,7 @@ CmdHistoryMonthly::CmdHistoryMonthly () } //////////////////////////////////////////////////////////////////////////////// -int CmdHistoryMonthly::execute (const std::string&, std::string& output) +int CmdHistoryMonthly::execute (std::string& output) { int rc = 0; std::map groups; // Represents any month with data @@ -202,7 +201,7 @@ CmdHistoryAnnual::CmdHistoryAnnual () } //////////////////////////////////////////////////////////////////////////////// -int CmdHistoryAnnual::execute (const std::string&, std::string& output) +int CmdHistoryAnnual::execute (std::string& output) { int rc = 0; std::map groups; // Represents any month with data @@ -355,7 +354,7 @@ CmdGHistoryMonthly::CmdGHistoryMonthly () } //////////////////////////////////////////////////////////////////////////////// -int CmdGHistoryMonthly::execute (const std::string&, std::string& output) +int CmdGHistoryMonthly::execute (std::string& output) { int rc = 0; std::map groups; // Represents any month with data @@ -551,7 +550,7 @@ CmdGHistoryAnnual::CmdGHistoryAnnual () } //////////////////////////////////////////////////////////////////////////////// -int CmdGHistoryAnnual::execute (const std::string&, std::string& output) +int CmdGHistoryAnnual::execute (std::string& output) { int rc = 0; std::map groups; // Represents any month with data diff --git a/src/commands/CmdHistory.h b/src/commands/CmdHistory.h index fa5a23df6..54741d630 100644 --- a/src/commands/CmdHistory.h +++ b/src/commands/CmdHistory.h @@ -35,28 +35,28 @@ class CmdHistoryMonthly : public Command { public: CmdHistoryMonthly (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdHistoryAnnual : public Command { public: CmdHistoryAnnual (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdGHistoryMonthly : public Command { public: CmdGHistoryMonthly (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdGHistoryAnnual : public Command { public: CmdGHistoryAnnual (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdIDs.cpp b/src/commands/CmdIDs.cpp index 2f59191fb..08e00dff9 100644 --- a/src/commands/CmdIDs.cpp +++ b/src/commands/CmdIDs.cpp @@ -45,7 +45,7 @@ CmdIDs::CmdIDs () } //////////////////////////////////////////////////////////////////////////////// -int CmdIDs::execute (const std::string&, std::string& output) +int CmdIDs::execute (std::string& output) { // Scan the pending tasks, applying any filter. std::vector tasks; @@ -78,7 +78,7 @@ CmdCompletionIds::CmdCompletionIds () } //////////////////////////////////////////////////////////////////////////////// -int CmdCompletionIds::execute (const std::string&, std::string& output) +int CmdCompletionIds::execute (std::string& output) { std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -116,7 +116,7 @@ CmdZshCompletionIds::CmdZshCompletionIds () } //////////////////////////////////////////////////////////////////////////////// -int CmdZshCompletionIds::execute (const std::string&, std::string& output) +int CmdZshCompletionIds::execute (std::string& output) { std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); diff --git a/src/commands/CmdIDs.h b/src/commands/CmdIDs.h index 4a8432125..d945bea53 100644 --- a/src/commands/CmdIDs.h +++ b/src/commands/CmdIDs.h @@ -35,21 +35,21 @@ class CmdIDs : public Command { public: CmdIDs (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdCompletionIds : public Command { public: CmdCompletionIds (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdZshCompletionIds : public Command { public: CmdZshCompletionIds (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdImport.cpp b/src/commands/CmdImport.cpp index 83e5c99dd..f332c6a12 100644 --- a/src/commands/CmdImport.cpp +++ b/src/commands/CmdImport.cpp @@ -739,6 +739,7 @@ std::string CmdImport::todoSh_2_0 (const std::vector & lines) std::vector ::const_iterator it; for (it = lines.begin (); it != lines.end (); ++it) { +/* try { context.args.clear (); @@ -802,12 +803,10 @@ std::string CmdImport::todoSh_2_0 (const std::vector & lines) } } -/* - context.task.clear (); - context.cmd.command = ""; - context.parse (); - decorateTask (context.task); -*/ +// context.task.clear (); +// context.cmd.command = ""; +// context.parse (); +// decorateTask (context.task); // Override the Task::pending that decorateTask applies. if (!isPending) @@ -837,6 +836,7 @@ std::string CmdImport::todoSh_2_0 (const std::vector & lines) context.clearMessages (); failed.push_back (*it); } +*/ } context.tdb.commit (); @@ -869,6 +869,7 @@ std::string CmdImport::text (const std::vector & lines) std::vector ::const_iterator it; for (it = lines.begin (); it != lines.end (); ++it) { +/* std::string line = *it; // Strip comments @@ -885,12 +886,10 @@ std::string CmdImport::text (const std::vector & lines) context.args.clear (); split (context.args, std::string ("add ") + line, ' '); -/* - context.task.clear (); - context.cmd.command = ""; - context.parse (); - decorateTask (context.task); -*/ +// context.task.clear (); +// context.cmd.command = ""; +// context.parse (); +// decorateTask (context.task); context.tdb.add (context.task); context.clearMessages (); @@ -902,6 +901,7 @@ std::string CmdImport::text (const std::vector & lines) failed.push_back (line); } } +*/ } context.tdb.commit (); @@ -1284,7 +1284,7 @@ std::string CmdImport::YAML (const std::vector & lines) } //////////////////////////////////////////////////////////////////////////////// -int CmdImport::execute (const std::string&, std::string& output) +int CmdImport::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdImport.h b/src/commands/CmdImport.h index bb426ebd7..1ffc23e56 100644 --- a/src/commands/CmdImport.h +++ b/src/commands/CmdImport.h @@ -35,7 +35,7 @@ class CmdImport : public Command { public: CmdImport (); - int execute (const std::string&, std::string&); + int execute (std::string&); private: enum fileType diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 19b4dfaa7..00de8b311 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -47,7 +47,7 @@ CmdInfo::CmdInfo () } //////////////////////////////////////////////////////////////////////////////// -int CmdInfo::execute (const std::string&, std::string& output) +int CmdInfo::execute (std::string& output) { int rc = 0; diff --git a/src/commands/CmdInfo.h b/src/commands/CmdInfo.h index c4d90b792..30c637acc 100644 --- a/src/commands/CmdInfo.h +++ b/src/commands/CmdInfo.h @@ -35,7 +35,7 @@ class CmdInfo : public Command { public: CmdInfo (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdInstall.cpp b/src/commands/CmdInstall.cpp index ae716fd95..1e774838d 100644 --- a/src/commands/CmdInstall.cpp +++ b/src/commands/CmdInstall.cpp @@ -47,7 +47,7 @@ CmdInstall::CmdInstall () // Generate UUID // Call the "install" function once, store results in rc: // extension.= -int CmdInstall::execute (const std::string&, std::string&) +int CmdInstall::execute (std::string&) { return 1; } diff --git a/src/commands/CmdInstall.h b/src/commands/CmdInstall.h index c7718735c..687aa5fa0 100644 --- a/src/commands/CmdInstall.h +++ b/src/commands/CmdInstall.h @@ -35,7 +35,7 @@ class CmdInstall : public Command { public: CmdInstall (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdLog.cpp b/src/commands/CmdLog.cpp index 72c33d88f..9c696e7e6 100644 --- a/src/commands/CmdLog.cpp +++ b/src/commands/CmdLog.cpp @@ -45,7 +45,7 @@ CmdLog::CmdLog () } //////////////////////////////////////////////////////////////////////////////// -int CmdLog::execute (const std::string&, std::string& output) +int CmdLog::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdLog.h b/src/commands/CmdLog.h index 35700dee9..4d43584bb 100644 --- a/src/commands/CmdLog.h +++ b/src/commands/CmdLog.h @@ -35,7 +35,7 @@ class CmdLog : public Command { public: CmdLog (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdLogo.cpp b/src/commands/CmdLogo.cpp index cb02de2b5..f6d06c49e 100644 --- a/src/commands/CmdLogo.cpp +++ b/src/commands/CmdLogo.cpp @@ -47,7 +47,7 @@ CmdLogo::CmdLogo () // Generate UUID // Call the "install" function once, store results in rc: // extension.= -int CmdLogo::execute (const std::string&, std::string& output) +int CmdLogo::execute (std::string& output) { static const char* data[] = { diff --git a/src/commands/CmdLogo.h b/src/commands/CmdLogo.h index 33bfbbaa4..cd1ba7b10 100644 --- a/src/commands/CmdLogo.h +++ b/src/commands/CmdLogo.h @@ -35,7 +35,7 @@ class CmdLogo : public Command { public: CmdLogo (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdMerge.cpp b/src/commands/CmdMerge.cpp index e2ea33493..1b1b4f574 100644 --- a/src/commands/CmdMerge.cpp +++ b/src/commands/CmdMerge.cpp @@ -47,7 +47,7 @@ CmdMerge::CmdMerge () } //////////////////////////////////////////////////////////////////////////////// -int CmdMerge::execute (const std::string&, std::string& output) +int CmdMerge::execute (std::string& output) { std::string file = trim (context.task.get ("description")); std::string pushfile = ""; @@ -93,7 +93,7 @@ int CmdMerge::execute (const std::string&, std::string& output) context.task.set ("description", uri.data); std::string out; - context.commands["push"]->execute ("", out); + context.commands["push"]->execute (out); } } else diff --git a/src/commands/CmdMerge.h b/src/commands/CmdMerge.h index c3720453f..636232684 100644 --- a/src/commands/CmdMerge.h +++ b/src/commands/CmdMerge.h @@ -35,7 +35,7 @@ class CmdMerge : public Command { public: CmdMerge (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdModify.cpp b/src/commands/CmdModify.cpp index 428b6c1ad..6d379e926 100644 --- a/src/commands/CmdModify.cpp +++ b/src/commands/CmdModify.cpp @@ -48,7 +48,7 @@ CmdModify::CmdModify () } //////////////////////////////////////////////////////////////////////////////// -int CmdModify::execute (const std::string&, std::string& output) +int CmdModify::execute (std::string& output) { int count = 0; std::stringstream out; diff --git a/src/commands/CmdModify.h b/src/commands/CmdModify.h index 351b1bdda..59d2c9c6b 100644 --- a/src/commands/CmdModify.h +++ b/src/commands/CmdModify.h @@ -35,7 +35,7 @@ class CmdModify : public Command { public: CmdModify (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdPrepend.cpp b/src/commands/CmdPrepend.cpp index 9fbb4ed2a..872f3279a 100644 --- a/src/commands/CmdPrepend.cpp +++ b/src/commands/CmdPrepend.cpp @@ -44,7 +44,7 @@ CmdPrepend::CmdPrepend () } //////////////////////////////////////////////////////////////////////////////// -int CmdPrepend::execute (const std::string&, std::string& output) +int CmdPrepend::execute (std::string& output) { if (!context.task.has ("description")) throw std::string ("Additional text must be provided."); diff --git a/src/commands/CmdPrepend.h b/src/commands/CmdPrepend.h index 8ef556dfe..32a627d7d 100644 --- a/src/commands/CmdPrepend.h +++ b/src/commands/CmdPrepend.h @@ -35,7 +35,7 @@ class CmdPrepend : public Command { public: CmdPrepend (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdProjects.cpp b/src/commands/CmdProjects.cpp index 80b9cd895..35a3e9b73 100644 --- a/src/commands/CmdProjects.cpp +++ b/src/commands/CmdProjects.cpp @@ -44,7 +44,7 @@ CmdProjects::CmdProjects () } //////////////////////////////////////////////////////////////////////////////// -int CmdProjects::execute (const std::string&, std::string& output) +int CmdProjects::execute (std::string& output) { int rc = 0; std::stringstream out; @@ -142,7 +142,7 @@ CmdCompletionProjects::CmdCompletionProjects () } //////////////////////////////////////////////////////////////////////////////// -int CmdCompletionProjects::execute (const std::string&, std::string& output) +int CmdCompletionProjects::execute (std::string& output) { std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); diff --git a/src/commands/CmdProjects.h b/src/commands/CmdProjects.h index b63b28f77..ebb5c4c14 100644 --- a/src/commands/CmdProjects.h +++ b/src/commands/CmdProjects.h @@ -35,14 +35,14 @@ class CmdProjects : public Command { public: CmdProjects (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdCompletionProjects : public Command { public: CmdCompletionProjects (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdPull.cpp b/src/commands/CmdPull.cpp index 91ef18653..c9b94a08c 100644 --- a/src/commands/CmdPull.cpp +++ b/src/commands/CmdPull.cpp @@ -46,7 +46,7 @@ CmdPull::CmdPull () } //////////////////////////////////////////////////////////////////////////////// -int CmdPull::execute (const std::string&, std::string& output) +int CmdPull::execute (std::string& output) { std::string file = trim (context.task.get ("description")); diff --git a/src/commands/CmdPull.h b/src/commands/CmdPull.h index 3e77f824e..d75948424 100644 --- a/src/commands/CmdPull.h +++ b/src/commands/CmdPull.h @@ -35,7 +35,7 @@ class CmdPull : public Command { public: CmdPull (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdPush.cpp b/src/commands/CmdPush.cpp index 3660b1cd5..addff1627 100644 --- a/src/commands/CmdPush.cpp +++ b/src/commands/CmdPush.cpp @@ -48,7 +48,7 @@ CmdPush::CmdPush () //////////////////////////////////////////////////////////////////////////////// // Transfers the local data (from rc.location.data) to the remote path. Because // this is potentially on another machine, no checking can be performed. -int CmdPush::execute (const std::string&, std::string& output) +int CmdPush::execute (std::string& output) { std::string file = trim (context.task.get ("description")); diff --git a/src/commands/CmdPush.h b/src/commands/CmdPush.h index eb54f2728..09eae8b88 100644 --- a/src/commands/CmdPush.h +++ b/src/commands/CmdPush.h @@ -35,7 +35,7 @@ class CmdPush : public Command { public: CmdPush (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdQuery.cpp b/src/commands/CmdQuery.cpp index 2bd4ebedc..24d87ae4f 100644 --- a/src/commands/CmdQuery.cpp +++ b/src/commands/CmdQuery.cpp @@ -42,7 +42,7 @@ CmdQuery::CmdQuery () } //////////////////////////////////////////////////////////////////////////////// -int CmdQuery::execute (const std::string&, std::string& output) +int CmdQuery::execute (std::string& output) { int rc = 0; diff --git a/src/commands/CmdQuery.h b/src/commands/CmdQuery.h index f94dc81de..df0a7f112 100644 --- a/src/commands/CmdQuery.h +++ b/src/commands/CmdQuery.h @@ -35,7 +35,7 @@ class CmdQuery : public Command { public: CmdQuery (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdReports.cpp b/src/commands/CmdReports.cpp index 2901a02df..7e39c12ad 100644 --- a/src/commands/CmdReports.cpp +++ b/src/commands/CmdReports.cpp @@ -45,7 +45,7 @@ CmdReports::CmdReports () } //////////////////////////////////////////////////////////////////////////////// -int CmdReports::execute (const std::string&, std::string& output) +int CmdReports::execute (std::string& output) { std::vector reports; diff --git a/src/commands/CmdReports.h b/src/commands/CmdReports.h index bb9bb72a2..090da5110 100644 --- a/src/commands/CmdReports.h +++ b/src/commands/CmdReports.h @@ -35,7 +35,7 @@ class CmdReports : public Command { public: CmdReports (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdShell.cpp b/src/commands/CmdShell.cpp index a2f7d091e..adb6ee203 100644 --- a/src/commands/CmdShell.cpp +++ b/src/commands/CmdShell.cpp @@ -45,7 +45,7 @@ CmdShell::CmdShell () } //////////////////////////////////////////////////////////////////////////////// -int CmdShell::execute (const std::string&, std::string&) +int CmdShell::execute (std::string&) { // Display some kind of welcome message. Color bold (Color::nocolor, Color::nocolor, false, true, false); @@ -85,6 +85,7 @@ int CmdShell::execute (const std::string&, std::string&) { try { +/* context.clear (); std::vector args; split (args, decoratedCommand, ' '); @@ -94,6 +95,7 @@ int CmdShell::execute (const std::string&, std::string&) context.initialize (0, NULL); context.run (); +*/ } catch (std::string& error) diff --git a/src/commands/CmdShell.h b/src/commands/CmdShell.h index d54c6cf48..54bc9d2f8 100644 --- a/src/commands/CmdShell.h +++ b/src/commands/CmdShell.h @@ -35,7 +35,7 @@ class CmdShell : public Command { public: CmdShell (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 69f323e7a..dcb84e662 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -50,9 +50,10 @@ CmdShow::CmdShow () } //////////////////////////////////////////////////////////////////////////////// -int CmdShow::execute (const std::string&, std::string& output) +int CmdShow::execute (std::string& output) { int rc = 0; +/* std::stringstream out; // Obtain the arguments from the description. That way, things like '--' @@ -308,6 +309,7 @@ int CmdShow::execute (const std::string&, std::string& output) } output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdShow.h b/src/commands/CmdShow.h index cfe037330..aa7ec7f33 100644 --- a/src/commands/CmdShow.h +++ b/src/commands/CmdShow.h @@ -35,7 +35,7 @@ class CmdShow : public Command { public: CmdShow (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdStart.cpp b/src/commands/CmdStart.cpp index 92412040a..9149c8bd5 100644 --- a/src/commands/CmdStart.cpp +++ b/src/commands/CmdStart.cpp @@ -43,7 +43,7 @@ CmdStart::CmdStart () } //////////////////////////////////////////////////////////////////////////////// -int CmdStart::execute (const std::string&, std::string& output) +int CmdStart::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdStart.h b/src/commands/CmdStart.h index b5bce29e3..2ec6e6d12 100644 --- a/src/commands/CmdStart.h +++ b/src/commands/CmdStart.h @@ -35,7 +35,7 @@ class CmdStart : public Command { public: CmdStart (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdStatistics.cpp b/src/commands/CmdStatistics.cpp index 6ae7b98e8..c92a1cd0d 100644 --- a/src/commands/CmdStatistics.cpp +++ b/src/commands/CmdStatistics.cpp @@ -49,7 +49,7 @@ CmdStatistics::CmdStatistics () } //////////////////////////////////////////////////////////////////////////////// -int CmdStatistics::execute (const std::string&, std::string& output) +int CmdStatistics::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdStatistics.h b/src/commands/CmdStatistics.h index e5bbf5cee..17612a005 100644 --- a/src/commands/CmdStatistics.h +++ b/src/commands/CmdStatistics.h @@ -35,7 +35,7 @@ class CmdStatistics : public Command { public: CmdStatistics (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdStop.cpp b/src/commands/CmdStop.cpp index fe012369e..86493a81c 100644 --- a/src/commands/CmdStop.cpp +++ b/src/commands/CmdStop.cpp @@ -43,7 +43,7 @@ CmdStop::CmdStop () } //////////////////////////////////////////////////////////////////////////////// -int CmdStop::execute (const std::string&, std::string& output) +int CmdStop::execute (std::string& output) { int rc = 0; std::stringstream out; diff --git a/src/commands/CmdStop.h b/src/commands/CmdStop.h index c5b5833db..6cf99479b 100644 --- a/src/commands/CmdStop.h +++ b/src/commands/CmdStop.h @@ -35,7 +35,7 @@ class CmdStop : public Command { public: CmdStop (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdSummary.cpp b/src/commands/CmdSummary.cpp index 87a9c2002..0b21b01f1 100644 --- a/src/commands/CmdSummary.cpp +++ b/src/commands/CmdSummary.cpp @@ -50,7 +50,7 @@ CmdSummary::CmdSummary () // Project Remaining Avg Age Complete 0% 100% // A 12 13d 55% XXXXXXXXXXXXX----------- // B 109 3d 12h 10% XXX--------------------- -int CmdSummary::execute (const std::string&, std::string& output) +int CmdSummary::execute (std::string& output) { int rc = 0; diff --git a/src/commands/CmdSummary.h b/src/commands/CmdSummary.h index 29e6182b7..7066452f4 100644 --- a/src/commands/CmdSummary.h +++ b/src/commands/CmdSummary.h @@ -35,7 +35,7 @@ class CmdSummary : public Command { public: CmdSummary (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdTags.cpp b/src/commands/CmdTags.cpp index 198cda331..c9096545f 100644 --- a/src/commands/CmdTags.cpp +++ b/src/commands/CmdTags.cpp @@ -46,7 +46,7 @@ CmdTags::CmdTags () } //////////////////////////////////////////////////////////////////////////////// -int CmdTags::execute (const std::string&, std::string& output) +int CmdTags::execute (std::string& output) { int rc = 0; std::stringstream out; @@ -131,7 +131,7 @@ CmdCompletionTags::CmdCompletionTags () } //////////////////////////////////////////////////////////////////////////////// -int CmdCompletionTags::execute (const std::string&, std::string& output) +int CmdCompletionTags::execute (std::string& output) { std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); diff --git a/src/commands/CmdTags.h b/src/commands/CmdTags.h index e2f8953ed..6f5584e9f 100644 --- a/src/commands/CmdTags.h +++ b/src/commands/CmdTags.h @@ -35,14 +35,14 @@ class CmdTags : public Command { public: CmdTags (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdCompletionTags : public Command { public: CmdCompletionTags (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index a6fcc3722..0e887f6f4 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -46,7 +46,7 @@ CmdTimesheet::CmdTimesheet () } //////////////////////////////////////////////////////////////////////////////// -int CmdTimesheet::execute (const std::string&, std::string& output) +int CmdTimesheet::execute (std::string& output) { int rc = 0; diff --git a/src/commands/CmdTimesheet.h b/src/commands/CmdTimesheet.h index 2ea5ca5bb..f78995edd 100644 --- a/src/commands/CmdTimesheet.h +++ b/src/commands/CmdTimesheet.h @@ -35,7 +35,7 @@ class CmdTimesheet : public Command { public: CmdTimesheet (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdTip.cpp b/src/commands/CmdTip.cpp index d2f1ef925..edce8a45c 100644 --- a/src/commands/CmdTip.cpp +++ b/src/commands/CmdTip.cpp @@ -42,7 +42,7 @@ CmdTip::CmdTip () } //////////////////////////////////////////////////////////////////////////////// -int CmdTip::execute (const std::string&, std::string&) +int CmdTip::execute (std::string&) { // TODO Read tips file, pick one, display it. return 0; diff --git a/src/commands/CmdTip.h b/src/commands/CmdTip.h index df34e19ca..1cd482c98 100644 --- a/src/commands/CmdTip.h +++ b/src/commands/CmdTip.h @@ -35,7 +35,7 @@ class CmdTip : public Command { public: CmdTip (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdUndo.cpp b/src/commands/CmdUndo.cpp index 66f6d7031..5faeac23d 100644 --- a/src/commands/CmdUndo.cpp +++ b/src/commands/CmdUndo.cpp @@ -41,7 +41,7 @@ CmdUndo::CmdUndo () } //////////////////////////////////////////////////////////////////////////////// -int CmdUndo::execute (const std::string&, std::string& output) +int CmdUndo::execute (std::string& output) { context.disallowModification (); diff --git a/src/commands/CmdUndo.h b/src/commands/CmdUndo.h index 471801622..18f799205 100644 --- a/src/commands/CmdUndo.h +++ b/src/commands/CmdUndo.h @@ -35,7 +35,7 @@ class CmdUndo : public Command { public: CmdUndo (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdUrgency.cpp b/src/commands/CmdUrgency.cpp index be8aacd83..3bcb0d196 100644 --- a/src/commands/CmdUrgency.cpp +++ b/src/commands/CmdUrgency.cpp @@ -44,7 +44,7 @@ CmdUrgency::CmdUrgency () } //////////////////////////////////////////////////////////////////////////////// -int CmdUrgency::execute (const std::string&, std::string& output) +int CmdUrgency::execute (std::string& output) { // Get all the tasks. std::vector tasks; diff --git a/src/commands/CmdUrgency.h b/src/commands/CmdUrgency.h index 25dbe30e2..d8cf47d8d 100644 --- a/src/commands/CmdUrgency.h +++ b/src/commands/CmdUrgency.h @@ -35,7 +35,7 @@ class CmdUrgency : public Command { public: CmdUrgency (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/CmdVersion.cpp b/src/commands/CmdVersion.cpp index 51569a697..9460c593f 100644 --- a/src/commands/CmdVersion.cpp +++ b/src/commands/CmdVersion.cpp @@ -46,7 +46,7 @@ CmdVersion::CmdVersion () } //////////////////////////////////////////////////////////////////////////////// -int CmdVersion::execute (const std::string&, std::string& output) +int CmdVersion::execute (std::string& output) { std::stringstream out; @@ -128,9 +128,7 @@ CmdCompletionVersion::CmdCompletionVersion () } //////////////////////////////////////////////////////////////////////////////// -int CmdCompletionVersion::execute ( - const std::string&, - std::string& output) +int CmdCompletionVersion::execute (std::string& output) { #ifdef HAVE_COMMIT output = COMMIT; diff --git a/src/commands/CmdVersion.h b/src/commands/CmdVersion.h index 99523b17a..ac4879df7 100644 --- a/src/commands/CmdVersion.h +++ b/src/commands/CmdVersion.h @@ -35,14 +35,14 @@ class CmdVersion : public Command { public: CmdVersion (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; class CmdCompletionVersion : public Command { public: CmdCompletionVersion (); - int execute (const std::string&, std::string&); + int execute (std::string&); }; #endif diff --git a/src/commands/Command.h b/src/commands/Command.h index 13f0b92d9..7ffaf657f 100644 --- a/src/commands/Command.h +++ b/src/commands/Command.h @@ -47,7 +47,7 @@ public: std::string description () const; bool read_only () const; bool displays_id () const; - virtual int execute (const std::string&, std::string&) = 0; + virtual int execute (std::string&) = 0; protected: std::string _keyword; diff --git a/src/en-US.h b/src/en-US.h index 92cbe5c66..327750582 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -108,6 +108,9 @@ #define STRING_CMD_SHOW_CONF_VAR "Config Variable" #define STRING_CMD_SHOW_CONF_VALUE "Value" +// Config +#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake." + // Context #define STRING_CONTEXT_CREATE_RC "A configuration file could not be found in {1}\n\nWould you like a sample {2} created, so taskwarrior can proceed?" #define STRING_CONTEXT_NEED_RC "Cannot proceed without rc file." diff --git a/src/main.cpp b/src/main.cpp index 2f8e18569..1bc6c5586 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,7 +40,7 @@ Context context; -int main (int argc, char** argv) +int main (int argc, const char** argv) { // Set up randomness. #ifdef CYGWIN @@ -63,7 +63,7 @@ int main (int argc, char** argv) try { - context.initialize (argc, (const char**)argv); + context.initialize (argc, argv); status = context.run (); }