diff options
Diffstat (limited to 'src/Client/CommandParser.h')
-rw-r--r-- | src/Client/CommandParser.h | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h index ca9b59e..a7157ed 100644 --- a/src/Client/CommandParser.h +++ b/src/Client/CommandParser.h @@ -23,6 +23,7 @@ #include <Common/HostInfo.h> #include <Common/XmlPacket.h> +#include <boost/function.hpp> #include <boost/smart_ptr.hpp> #include <map> @@ -37,15 +38,21 @@ class Connection; namespace Client { +class SystemCommands; +class UserCommands; + class CommandParser { private: + friend class SystemCommands; + friend class UserCommands; + struct Command { const char* commands[3]; const char* cmdline; const char* desc; const char* longdesc; - void (CommandParser::*funcPtr) (const std::vector<std::string> &args); + boost::function2<void, const std::vector<std::string>, Common::Connection*> function; }; static const Command commands[]; @@ -56,26 +63,14 @@ class CommandParser { bool disconnect; - const Command* findCommand(const std::string& command); - void printUsage(const std::string& command); - - std::map<std::string, Common::HostInfo> parseHostList(const std::vector<std::string> &args, bool mustBeActive = false); + static const Command* findCommand(const std::string& command); - void printFSInfo(boost::shared_ptr<const Common::XmlPacket> &packet); - void printHostStatus(boost::shared_ptr<const Common::XmlPacket> &packet); + static void printUsage(const std::string& command); + static std::map<std::string, Common::HostInfo> parseHostList(const std::vector<std::string> &args, bool mustBeActive = false); - void fsinfoCommand(const std::vector<std::string> &args); - void helpCommand(const std::vector<std::string> &args); - void listHostsCommand(const std::vector<std::string> &args); - void rebootCommand(const std::vector<std::string> &args); - void shutdownCommand(const std::vector<std::string> &args); - void statusCommand(const std::vector<std::string> &args); - void userInfoCommand(const std::vector<std::string> &args); - void listUsersCommand(const std::vector<std::string> &args); - void listUserGroupsCommand(const std::vector<std::string> &args); - void listGroupsCommand(const std::vector<std::string> &args); - void listGroupUsersCommand(const std::vector<std::string> &args); - void exitCommand(const std::vector<std::string>&); + static void helpCommand(const std::vector<std::string> &args, Common::Connection *connection); + static void listHostsCommand(const std::vector<std::string> &args, Common::Connection *connection); + static void exitCommand(const std::vector<std::string> &args, Common::Connection *connection); CommandParser() : connection(0), disconnect(false) {} @@ -95,7 +90,7 @@ class CommandParser { bool parse(const std::string &cmd); void requestDisconnect() { - exitCommand(std::vector<std::string>()); + exitCommand(std::vector<std::string>(), connection); } bool willDisconnect() const { |