From 8eb965d71d7d719e8ef16323a34e5209e8eb966a Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 20 Jul 2015 02:38:59 +0000 Subject: [PATCH] zcmdcat: Initial infrastructure. --- src/commands/Command.cpp | 18 +++++++++++++++++- src/commands/Command.h | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index b07313b9f..f9af27f37 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -193,9 +193,25 @@ void Command::factory (std::map & all) } } +//////////////////////////////////////////////////////////////////////////////// +const std::map 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 () -: _usage ("") +: _category(Category::unassigned) +, _usage ("") , _description ("") , _read_only (true) , _displays_id (true) diff --git a/src/commands/Command.h b/src/commands/Command.h index 65828e135..c81cdf712 100644 --- a/src/commands/Command.h +++ b/src/commands/Command.h @@ -47,8 +47,24 @@ public: bool displays_id () const; 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: bool permission (const Task&, const std::string&, unsigned int); + static const std::map categoryNames; protected: std::string _keyword;