zcmdcat: Initial infrastructure.

This commit is contained in:
Daniel Shahaf 2015-07-20 02:38:59 +00:00 committed by Paul Beckingham
parent f5571c80c6
commit 8eb965d71d
2 changed files with 33 additions and 1 deletions

View file

@ -193,9 +193,25 @@ void Command::factory (std::map <std::string, Command*>& all)
} }
} }
////////////////////////////////////////////////////////////////////////////////
const std::map <Command::Category, std::string> Command::categoryNames =
{
// These strings are intentionally not l10n'd: they are used as identifiers.
{Command::Category::unassigned, "unassigned"} // should never happen
,{Command::Category::interrogator, "interrogator"}
,{Command::Category::report, "report"}
,{Command::Category::operation, "operation"}
,{Command::Category::graphs, "graphs" }
,{Command::Category::config, "config" }
,{Command::Category::migration, "migration"}
,{Command::Category::misc, "misc" }
,{Command::Category::internal, "internal"}
};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Command::Command () Command::Command ()
: _usage ("") : _category(Category::unassigned)
, _usage ("")
, _description ("") , _description ("")
, _read_only (true) , _read_only (true)
, _displays_id (true) , _displays_id (true)

View file

@ -47,8 +47,24 @@ public:
bool displays_id () const; bool displays_id () const;
virtual int execute (std::string&) = 0; virtual int execute (std::string&) = 0;
enum class Category
{
unassigned,
interrogator,
report,
operation,
graphs,
config,
migration,
misc,
internal,
// Whenever you extend this enum, update categoryNames.
};
Category _category;
protected: protected:
bool permission (const Task&, const std::string&, unsigned int); bool permission (const Task&, const std::string&, unsigned int);
static const std::map <Command::Category, std::string> categoryNames;
protected: protected:
std::string _keyword; std::string _keyword;