Built in implementation of EShell.
More...
#include <Shell.h>
|
struct | Command |
| Container for a command callback and its argument processor. More...
|
|
struct | flag |
| Contains various shell flags. More...
|
|
Built in implementation of EShell.
- See also
- Terminal
◆ callback_t
Command callback.
Called when a command is invoked.
◆ errCallback_t
Error callback.
Called when an error is detected.
◆ noCommandCallback_t
No-command callback.
Return value should the be text to display to the user. The parameter is the command that was given.
◆ Shell()
Construct a shell with an error callback.
No errors are set in the constructor ATM, but it may still be a good idea to assure that errors get processed correctly.
- Note
- The error callback isn't set if it's not callable
- Parameters
-
[in] | callback | A callable callback |
- See also
- setErrorCallback(const errCallback_t &callback)
◆ addCommand()
Add a new command to the Shell.
- Note
- If the parameter
callback
is not callable, an error is set and the command is not added.
- Parameters
-
[in] | name | The initial alias for the command |
[in] | filter | The command filter for the command |
[in] | callback | A callable callback for the command |
- See also
- alias(const std::string &name)
-
input(const std::string &commandString)
- Returns
- ID of the command (used to modify it), or zero if an error occurred.
◆ alias() [1/2]
void etm::Shell::alias |
( |
comid_t |
id, |
|
|
const std::string & |
name |
|
) |
| |
Associate another name with the given command.
- Note
- An error is set if
id
is invalid (doesn't exist)
-
If
name
already exists as an alias to some other command, that alias gets re-pointed to the last command. In other words, this function overwrites any previous alias of the same name.
- Parameters
-
[in] | id | The ID of the command |
[in] | name | The alias |
◆ alias() [2/2]
void etm::Shell::alias |
( |
const std::string & |
name | ) |
|
Associate another name with the last added command.
- Note
- An error is set if there aren't any commands
-
If
name
already exists as an alias to some other command, that alias gets re-pointed to the last command. In other words, this function overwrites any previous alias of the same name.
- Parameters
-
◆ getErrorCallback()
◆ getNoCommandCallback()
◆ getPrompt()
std::string etm::Shell::getPrompt |
( |
| ) |
|
◆ input()
void etm::Shell::input |
( |
const std::string & |
commandString | ) |
|
|
overridevirtual |
Send a command string to the shell to be processed.
Typically from user input.
- Parameters
-
[in] | commandString | The command string |
Implements etm::EShell.
◆ postError()
void etm::Shell::postError |
( |
const std::string & |
location, |
|
|
const std::string & |
message, |
|
|
bool |
severe |
|
) |
| |
Send an error to the error callback.
The given parameters are packaged into a shellError object.
- Parameters
-
[in] | location | The location at which the error was detected |
[in] | message | The error message |
[in] | severe | Whether the error is severe or not |
◆ setErrorCallback()
void etm::Shell::setErrorCallback |
( |
const errCallback_t & |
callback | ) |
|
◆ setFlags()
Set terminal flags.
- Parameters
-
[in] | flags | The flags to set |
- See also
- flag
◆ setNoCommandCallback()
◆ setPrompt()
void etm::Shell::setPrompt |
( |
const std::string & |
str | ) |
|
◆ setTerminal()
void etm::Shell::setTerminal |
( |
ETerminal & |
terminal | ) |
|
The documentation for this class was generated from the following file: