mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Commands
- Implemented CmdHelp object that replaces the report.cpp longUsage function, and builds the output dynamically from other Command objects. This is also why the help text right now is very short, as only a few commands are migrated. - Obsoleted longUsage function. - Updated task.1 man page with 'execute' command details. - Modified command.lua sample to include command usage. - Removed "help" from old Context::dispatch, which means "help" is the first migrated command. - Added usage and description to all Cmd* objects. - Implemented Command::usage and Command::description as base class methods that simply return data that is specified by the derived classes.
This commit is contained in:
parent
afc97d566c
commit
bc756637da
15 changed files with 477 additions and 91 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <iostream>
|
||||
#include <Command.h>
|
||||
#include <CmdExec.h>
|
||||
#include <CmdHelp.h>
|
||||
#include <CmdInstall.h>
|
||||
#include <CmdLogo.h>
|
||||
#include <Context.h>
|
||||
|
@ -38,7 +39,8 @@ extern Context context;
|
|||
Command* Command::factory (const std::string& name)
|
||||
{
|
||||
Command* command;
|
||||
if (name == "exec") command = new CmdExec ();
|
||||
if (name == "execute") command = new CmdExec ();
|
||||
else if (name == "help") command = new CmdHelp ();
|
||||
else if (name == "install") command = new CmdInstall ();
|
||||
else if (name == "_logo") command = new CmdLogo ();
|
||||
else
|
||||
|
@ -51,7 +53,9 @@ Command* Command::factory (const std::string& name)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Command::Command ()
|
||||
: _read_only (true)
|
||||
: _usage ("")
|
||||
, _description ("")
|
||||
, _read_only (true)
|
||||
, _displays_id (true)
|
||||
{
|
||||
}
|
||||
|
@ -59,6 +63,8 @@ Command::Command ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
Command::Command (const Command& other)
|
||||
{
|
||||
_usage = other._usage;
|
||||
_description = other._description;
|
||||
_read_only = other._read_only;
|
||||
_displays_id = other._displays_id;
|
||||
}
|
||||
|
@ -68,6 +74,8 @@ Command& Command::operator= (const Command& other)
|
|||
{
|
||||
if (this != &other)
|
||||
{
|
||||
_usage = other._usage;
|
||||
_description = other._description;
|
||||
_read_only = other._read_only;
|
||||
_displays_id = other._displays_id;
|
||||
}
|
||||
|
@ -78,7 +86,9 @@ Command& Command::operator= (const Command& other)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Command::operator== (const Command& other) const
|
||||
{
|
||||
return _read_only == other._read_only &&
|
||||
return _usage == other._usage &&
|
||||
_description == other._description &&
|
||||
_read_only == other._read_only &&
|
||||
_displays_id == other._displays_id;
|
||||
}
|
||||
|
||||
|
@ -87,6 +97,18 @@ Command::~Command ()
|
|||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Command::usage () const
|
||||
{
|
||||
return _usage;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Command::description () const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Command::read_only () const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue