mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Commands
- Migrated handleVersion to CmdVersion.
This commit is contained in:
parent
d892a0cbd2
commit
fc77e04b54
9 changed files with 174 additions and 86 deletions
|
@ -1,5 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
include_directories (${CMAKE_SOURCE_DIR}/src
|
include_directories (${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_SOURCE_DIR}/src
|
||||||
${CMAKE_SOURCE_DIR}/src/commands
|
${CMAKE_SOURCE_DIR}/src/commands
|
||||||
${CMAKE_SOURCE_DIR}/src/columns
|
${CMAKE_SOURCE_DIR}/src/columns
|
||||||
${TASK_INCLUDE_DIRS})
|
${TASK_INCLUDE_DIRS})
|
||||||
|
|
|
@ -177,7 +177,6 @@ void Cmd::load ()
|
||||||
commands.push_back ("summary");
|
commands.push_back ("summary");
|
||||||
commands.push_back ("timesheet");
|
commands.push_back ("timesheet");
|
||||||
commands.push_back ("undo");
|
commands.push_back ("undo");
|
||||||
commands.push_back ("version");
|
|
||||||
commands.push_back ("merge");
|
commands.push_back ("merge");
|
||||||
commands.push_back ("push");
|
commands.push_back ("push");
|
||||||
commands.push_back ("pull");
|
commands.push_back ("pull");
|
||||||
|
@ -272,7 +271,6 @@ bool Cmd::isReadOnlyCommand ()
|
||||||
command == "stats" ||
|
command == "stats" ||
|
||||||
command == "summary" ||
|
command == "summary" ||
|
||||||
command == "timesheet" ||
|
command == "timesheet" ||
|
||||||
command == "version" ||
|
|
||||||
validCustom (command))
|
validCustom (command))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,6 @@ int Context::dispatch (std::string &out)
|
||||||
// TODO Chain-of-command pattern dispatch.
|
// TODO Chain-of-command pattern dispatch.
|
||||||
if (cmd.command == "projects") { rc = handleProjects (out); }
|
if (cmd.command == "projects") { rc = handleProjects (out); }
|
||||||
else if (cmd.command == "colors") { rc = handleColor (out); }
|
else if (cmd.command == "colors") { rc = handleColor (out); }
|
||||||
else if (cmd.command == "version") { rc = handleVersion (out); }
|
|
||||||
else if (cmd.command == "config") { rc = handleConfig (out); }
|
else if (cmd.command == "config") { rc = handleConfig (out); }
|
||||||
else if (cmd.command == "show") { rc = handleShow (out); }
|
else if (cmd.command == "show") { rc = handleShow (out); }
|
||||||
else if (cmd.command == "stats") { rc = handleReportStats (out); }
|
else if (cmd.command == "stats") { rc = handleReportStats (out); }
|
||||||
|
|
|
@ -903,79 +903,6 @@ void handlePull (std::string& outs)
|
||||||
"'pull.default.uri' entry in your .taskrc file.");
|
"'pull.default.uri' entry in your .taskrc file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
int handleVersion (std::string& outs)
|
|
||||||
{
|
|
||||||
int rc = 0;
|
|
||||||
std::stringstream out;
|
|
||||||
|
|
||||||
// Create a table for the disclaimer.
|
|
||||||
int width = context.getWidth ();
|
|
||||||
ViewText disclaimer;
|
|
||||||
disclaimer.width (width);
|
|
||||||
disclaimer.add (Column::factory ("string", ""));
|
|
||||||
disclaimer.set (disclaimer.addRow (), 0,
|
|
||||||
"Taskwarrior may be copied only under the terms of the GNU General Public "
|
|
||||||
"License, which may be found in the taskwarrior source kit.");
|
|
||||||
|
|
||||||
// Create a table for the URL.
|
|
||||||
ViewText link;
|
|
||||||
link.width (width);
|
|
||||||
link.add (Column::factory ("string", ""));
|
|
||||||
link.set (link.addRow (), 0,
|
|
||||||
"Documentation for taskwarrior can be found using 'man task', 'man taskrc', "
|
|
||||||
"'man task-tutorial', 'man task-color', 'man task-sync', 'man task-faq' or at "
|
|
||||||
"http://taskwarrior.org");
|
|
||||||
|
|
||||||
Color bold ("bold");
|
|
||||||
|
|
||||||
out << "\n"
|
|
||||||
<< (context.color () ? bold.colorize (PACKAGE) : PACKAGE)
|
|
||||||
<< " "
|
|
||||||
<< (context.color () ? bold.colorize (VERSION) : VERSION)
|
|
||||||
<< " built for "
|
|
||||||
|
|
||||||
#if defined (DARWIN)
|
|
||||||
<< "darwin"
|
|
||||||
#elif defined (SOLARIS)
|
|
||||||
<< "solaris"
|
|
||||||
#elif defined (CYGWIN)
|
|
||||||
<< "cygwin"
|
|
||||||
#elif defined (OPENBSD)
|
|
||||||
<< "openbsd"
|
|
||||||
#elif defined (HAIKU)
|
|
||||||
<< "haiku"
|
|
||||||
#elif defined (FREEBSD)
|
|
||||||
<< "freebsd"
|
|
||||||
#elif defined (LINUX)
|
|
||||||
<< "linux"
|
|
||||||
#else
|
|
||||||
<< "unknown"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
<< "-readline"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBLUA
|
|
||||||
<< "-lua"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
<< "\n"
|
|
||||||
<< "Copyright (C) 2006 - 2011 P. Beckingham, F. Hernandez.\n"
|
|
||||||
#ifdef HAVE_LIBLUA
|
|
||||||
<< "Portions of this software Copyright (C) 1994 – 2008 Lua.org, PUC-Rio.\n"
|
|
||||||
#endif
|
|
||||||
<< "\n"
|
|
||||||
<< disclaimer.render ()
|
|
||||||
<< "\n"
|
|
||||||
<< link.render ()
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
outs = out.str ();
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int handleShow (std::string& outs)
|
int handleShow (std::string& outs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
include_directories (${CMAKE_SOURCE_DIR}/src
|
include_directories (${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_SOURCE_DIR}/src
|
||||||
${CMAKE_SOURCE_DIR}/src/commands
|
${CMAKE_SOURCE_DIR}/src/commands
|
||||||
${CMAKE_SOURCE_DIR}/src/columns
|
${CMAKE_SOURCE_DIR}/src/columns
|
||||||
${TASK_INCLUDE_DIRS})
|
${TASK_INCLUDE_DIRS})
|
||||||
|
|
||||||
set (commands_SRCS Command.cpp Command.h
|
set (commands_SRCS Command.cpp Command.h
|
||||||
CmdCustom.cpp CmdCustom.h
|
CmdCustom.cpp CmdCustom.h
|
||||||
CmdExec.cpp CmdExec.h
|
CmdExec.cpp CmdExec.h
|
||||||
CmdHelp.cpp CmdHelp.h
|
CmdHelp.cpp CmdHelp.h
|
||||||
CmdInstall.cpp CmdInstall.h
|
CmdInstall.cpp CmdInstall.h
|
||||||
CmdLogo.cpp CmdLogo.h
|
CmdLogo.cpp CmdLogo.h
|
||||||
CmdTags.cpp CmdTags.h
|
CmdTags.cpp CmdTags.h
|
||||||
CmdTip.cpp CmdTip.h)
|
CmdTip.cpp CmdTip.h
|
||||||
|
CmdVersion.cpp CmdVersion.h)
|
||||||
|
|
||||||
add_library (commands STATIC ${commands_SRCS})
|
add_library (commands STATIC ${commands_SRCS})
|
||||||
|
|
||||||
|
|
119
src/commands/CmdVersion.cpp
Normal file
119
src/commands/CmdVersion.cpp
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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 <sstream>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <Context.h>
|
||||||
|
#include <ViewText.h>
|
||||||
|
#include <cmake.h>
|
||||||
|
#include <CmdVersion.h>
|
||||||
|
|
||||||
|
extern Context context;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CmdVersion::CmdVersion ()
|
||||||
|
{
|
||||||
|
_keyword = "version";
|
||||||
|
_usage = "task version";
|
||||||
|
_description = "Shows the taskwarrior version number.";
|
||||||
|
_read_only = true;
|
||||||
|
_displays_id = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CmdVersion::execute (const std::string& command_line, std::string& output)
|
||||||
|
{
|
||||||
|
std::stringstream out;
|
||||||
|
|
||||||
|
// Create a table for the disclaimer.
|
||||||
|
int width = context.getWidth ();
|
||||||
|
ViewText disclaimer;
|
||||||
|
disclaimer.width (width);
|
||||||
|
disclaimer.add (Column::factory ("string", ""));
|
||||||
|
disclaimer.set (disclaimer.addRow (), 0,
|
||||||
|
"Taskwarrior may be copied only under the terms of the GNU General Public "
|
||||||
|
"License, which may be found in the taskwarrior source kit.");
|
||||||
|
|
||||||
|
// Create a table for the URL.
|
||||||
|
ViewText link;
|
||||||
|
link.width (width);
|
||||||
|
link.add (Column::factory ("string", ""));
|
||||||
|
link.set (link.addRow (), 0,
|
||||||
|
"Documentation for taskwarrior can be found using 'man task', 'man taskrc', "
|
||||||
|
"'man task-tutorial', 'man task-color', 'man task-sync', 'man task-faq' or at "
|
||||||
|
"http://taskwarrior.org");
|
||||||
|
|
||||||
|
Color bold ("bold");
|
||||||
|
|
||||||
|
out << "\n"
|
||||||
|
<< (context.color () ? bold.colorize (PACKAGE) : PACKAGE)
|
||||||
|
<< " "
|
||||||
|
<< (context.color () ? bold.colorize (VERSION) : VERSION)
|
||||||
|
<< " built for "
|
||||||
|
|
||||||
|
#if defined (DARWIN)
|
||||||
|
<< "darwin"
|
||||||
|
#elif defined (SOLARIS)
|
||||||
|
<< "solaris"
|
||||||
|
#elif defined (CYGWIN)
|
||||||
|
<< "cygwin"
|
||||||
|
#elif defined (OPENBSD)
|
||||||
|
<< "openbsd"
|
||||||
|
#elif defined (HAIKU)
|
||||||
|
<< "haiku"
|
||||||
|
#elif defined (FREEBSD)
|
||||||
|
<< "freebsd"
|
||||||
|
#elif defined (LINUX)
|
||||||
|
<< "linux"
|
||||||
|
#else
|
||||||
|
<< "unknown"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBREADLINE
|
||||||
|
<< "-readline"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLUA
|
||||||
|
<< "-lua"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
<< "\n"
|
||||||
|
<< "Copyright (C) 2006 - 2011 P. Beckingham, F. Hernandez.\n"
|
||||||
|
#ifdef HAVE_LIBLUA
|
||||||
|
<< "Portions of this software Copyright (C) 1994 – 2008 Lua.org, PUC-Rio.\n"
|
||||||
|
#endif
|
||||||
|
<< "\n"
|
||||||
|
<< disclaimer.render ()
|
||||||
|
<< "\n"
|
||||||
|
<< link.render ()
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
|
output = out.str ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
41
src/commands/CmdVersion.h
Normal file
41
src/commands/CmdVersion.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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_CMDVERSION
|
||||||
|
#define INCLUDED_CMDVERSION
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <Command.h>
|
||||||
|
|
||||||
|
class CmdVersion : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CmdVersion ();
|
||||||
|
int execute (const std::string&, std::string&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
|
@ -35,6 +35,7 @@
|
||||||
#include <CmdLogo.h>
|
#include <CmdLogo.h>
|
||||||
#include <CmdTags.h>
|
#include <CmdTags.h>
|
||||||
#include <CmdTip.h>
|
#include <CmdTip.h>
|
||||||
|
#include <CmdVersion.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -50,6 +51,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||||
c = new CmdLogo (); all[c->keyword ()] = c;
|
c = new CmdLogo (); all[c->keyword ()] = c;
|
||||||
c = new CmdTags (); all[c->keyword ()] = c;
|
c = new CmdTags (); all[c->keyword ()] = c;
|
||||||
c = new CmdTip (); all[c->keyword ()] = c;
|
c = new CmdTip (); all[c->keyword ()] = c;
|
||||||
|
c = new CmdVersion (); all[c->keyword ()] = c;
|
||||||
|
|
||||||
// Instantiate a command object for each custom report.
|
// Instantiate a command object for each custom report.
|
||||||
std::vector <std::string> variables;
|
std::vector <std::string> variables;
|
||||||
|
|
|
@ -66,7 +66,6 @@ int handleUrgency (std::string&);
|
||||||
int handleQuery (std::string&);
|
int handleQuery (std::string&);
|
||||||
int handleZshCompletionCommands (std::string&);
|
int handleZshCompletionCommands (std::string&);
|
||||||
int handleZshCompletionIDs (std::string&);
|
int handleZshCompletionIDs (std::string&);
|
||||||
int handleVersion (std::string&);
|
|
||||||
int handleConfig (std::string&);
|
int handleConfig (std::string&);
|
||||||
int handleShow (std::string&);
|
int handleShow (std::string&);
|
||||||
int handleDelete (std::string&);
|
int handleDelete (std::string&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue