HelpCommand.cc Source File
Back to the index.
Go to the documentation of this file.
33 :
Command(
"help",
"[command-name]")
46 Commands::const_iterator it;
48 if (arguments.size() > 1) {
53 if (arguments.size() == 1) {
55 if (arguments[0] ==
"root") {
58 "Shows the component tree which makes up the current emulation configuration.\n"
59 "Technically, 'root' is not a command, but the name of the root node. Typing\n"
60 "the name of any node in the configuration tree will dump the sub-tree starting\n"
61 "at that node, followed by that node's own variables.\n\n");
65 it = commands.find(arguments[0]);
66 if (it == commands.end()) {
68 "Command \"" + arguments[0] +
"\" unknown.\n");
77 string longhelp = arguments[0];
78 const string& argumentFormat = it->second->GetArgumentFormat();
79 if (argumentFormat !=
"")
80 longhelp +=
" " + argumentFormat;
81 int len = longhelp.length();
84 for (
int i=0; i<len; i++)
87 longhelp +=
"\n\n" + it->second->GetLongDescription();
88 if (longhelp[longhelp.length() - 1] !=
'\n')
93 if (it->second->MayBeReexecutedWithoutArgs())
95 "This command will be re-executed (without "
96 "arguments), if an empty command\n"
97 "line is issued.\n\n");
104 for (it = commands.begin(); it != commands.end(); ++ it) {
105 const Command& command = *it->second;
116 for (it = commands.begin(); it != commands.end(); ++ it) {
117 const Command& command = *it->second;
119 const string leadingSpaces =
" ";
120 const int nLeadingSpaces = 2;
126 while (str.length() < longest + nLeadingSpaces)
136 "----------------------------------------------\n");
138 "Shows the entire component tree.\n");
140 "Shows the component tree, from the named component.\n");
142 "Executes a method of a named component.\n");
144 "Prints the value of a variable of a named component.\n");
146 "Assigns a value to a variable of a named component.\n");
154 return "Shows a help message.";
160 return "Shows a summary of all available commands, or, "
161 "when given a specific command\n"
162 "name as an argument, shows a detailed description about "
map< string, refcount_ptr< Command > > Commands
virtual bool Execute(GXemul &gxemul, const vector< string > &arguments)
Executes the command on a given GXemul instance.
const string & GetArgumentFormat() const
Gets the argument format for the command.
virtual string GetShortDescription() const
Returns a short (one-line) description of the command.
CommandInterpreter & GetCommandInterpreter()
Gets a reference to the CommandInterpreter.
A Command is a named function, executed by the CommandInterpreter.
virtual void ShowDebugMessage(const string &msg)=0
Shows a debug message.
HelpCommand()
Constructs a HelpCommand.
const string & GetCommandName() const
Gets the name of the command.
virtual string GetLongDescription() const
Returns a long description/help message for the command.
const Commands & GetCommands() const
Gets a collection of all commands.
UI * GetUI()
Gets a pointer to the GXemul instance' active UI.
virtual string GetShortDescription() const =0
Returns a short (one-line) description of the command.
Generated on Tue Aug 25 2020 19:25:06 for GXemul by
1.8.18