diff --git a/src/Cmd.cpp b/src/Cmd.cpp index 93e09061c..ade432e38 100644 --- a/src/Cmd.cpp +++ b/src/Cmd.cpp @@ -134,7 +134,6 @@ void Cmd::load () commands.push_back ("_commands"); commands.push_back ("_ids"); commands.push_back ("_config"); - commands.push_back ("_version"); commands.push_back ("_urgency"); commands.push_back ("_query"); commands.push_back ("_zshcommands"); @@ -241,7 +240,6 @@ bool Cmd::isReadOnlyCommand () command == "_commands" || command == "_ids" || command == "_config" || - command == "_version" || command == "_urgency" || command == "_query" || command == "_zshcommands" || diff --git a/src/Context.cpp b/src/Context.cpp index dcf5ad245..cd7eeff5b 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -294,7 +294,6 @@ int Context::dispatch (std::string &out) else if (cmd.command == "_commands") { rc = handleCompletionCommands (out); } else if (cmd.command == "_ids") { rc = handleCompletionIDs (out); } else if (cmd.command == "_config") { rc = handleCompletionConfig (out); } - else if (cmd.command == "_version") { rc = handleCompletionVersion (out); } else if (cmd.command == "_urgency") { rc = handleUrgency (out); } else if (cmd.command == "_query") { rc = handleQuery (out); } else if (cmd.command == "_zshcommands") { rc = handleZshCompletionCommands (out); } diff --git a/src/command.cpp b/src/command.cpp index a1ccb5ebb..171af6268 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -411,20 +411,6 @@ int handleCompletionConfig (std::string& outs) return 0; } -//////////////////////////////////////////////////////////////////////////////// -// A simple version display for use by completion scripts and the task-update -// script. -int handleCompletionVersion (std::string& outs) -{ -#ifdef HAVE_COMMIT - outs = COMMIT; -#else - outs = VERSION; -#endif - outs += "\n"; - return 0; -} - //////////////////////////////////////////////////////////////////////////////// // Temporary command to display urgency for a task. int handleUrgency (std::string& outs) diff --git a/src/commands/CmdHelp.cpp b/src/commands/CmdHelp.cpp index 0c60e19ac..cab9a4dd3 100644 --- a/src/commands/CmdHelp.cpp +++ b/src/commands/CmdHelp.cpp @@ -242,10 +242,6 @@ int CmdHelp::execute (const std::string& command_line, std::string& output) view.set (row, 1, "task ids [filter]"); view.set (row, 2, "Shows only the IDs of matching tasks, in the form of a range."); - row = view.addRow (); - view.set (row, 1, "task version"); - view.set (row, 2, "Shows the task version number."); - row = view.addRow (); view.set (row, 1, "task show [all | substring]"); view.set (row, 2, "Shows the entire task configuration variables or the ones containing substring."); diff --git a/src/commands/CmdVersion.cpp b/src/commands/CmdVersion.cpp index fa38ff5ba..f0f78f52c 100644 --- a/src/commands/CmdVersion.cpp +++ b/src/commands/CmdVersion.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include extern Context context; @@ -117,3 +118,27 @@ int CmdVersion::execute (const std::string& command_line, std::string& output) } //////////////////////////////////////////////////////////////////////////////// +CmdCompletionVersion::CmdCompletionVersion () +{ + _keyword = "_version"; + _usage = "task _version"; + _description = "Shows only the taskwarrior version number."; + _read_only = true; + _displays_id = false; +} + +//////////////////////////////////////////////////////////////////////////////// +int CmdCompletionVersion::execute ( + const std::string& command_line, + std::string& output) +{ +#ifdef HAVE_COMMIT + output = COMMIT; +#else + output = VERSION; +#endif + output += "\n"; + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdVersion.h b/src/commands/CmdVersion.h index c4b463844..9f2079741 100644 --- a/src/commands/CmdVersion.h +++ b/src/commands/CmdVersion.h @@ -37,5 +37,12 @@ public: int execute (const std::string&, std::string&); }; +class CmdCompletionVersion : public Command +{ +public: + CmdCompletionVersion (); + int execute (const std::string&, std::string&); +}; + #endif //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 58659c608..db8efe765 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -45,13 +45,14 @@ void Command::factory (std::map & all) { Command* c; - c = new CmdExec (); all[c->keyword ()] = c; - c = new CmdHelp (); all[c->keyword ()] = c; - c = new CmdInstall (); all[c->keyword ()] = c; - c = new CmdLogo (); all[c->keyword ()] = c; - c = new CmdTags (); all[c->keyword ()] = c; - c = new CmdTip (); all[c->keyword ()] = c; - c = new CmdVersion (); all[c->keyword ()] = c; + c = new CmdExec (); all[c->keyword ()] = c; + c = new CmdHelp (); all[c->keyword ()] = c; + c = new CmdInstall (); all[c->keyword ()] = c; + c = new CmdLogo (); all[c->keyword ()] = c; + c = new CmdTags (); all[c->keyword ()] = c; + c = new CmdTip (); all[c->keyword ()] = c; + c = new CmdVersion (); all[c->keyword ()] = c; + c = new CmdCompletionVersion (); all[c->keyword ()] = c; // Instantiate a command object for each custom report. std::vector variables; diff --git a/src/main.h b/src/main.h index a79b8236a..254e3e221 100644 --- a/src/main.h +++ b/src/main.h @@ -61,7 +61,6 @@ int handleCompletionTags (std::string&); int handleCompletionCommands (std::string&); int handleCompletionIDs (std::string&); int handleCompletionConfig (std::string&); -int handleCompletionVersion (std::string&); int handleUrgency (std::string&); int handleQuery (std::string&); int handleZshCompletionCommands (std::string&);