34 #define SHELL_MAX_CMD_LEN 256
36 #define SHELL_MAX_CMD_LEN 64
51 class ShellCommandRegister
54 inline ShellCommandRegister(
const ShellCommandInfo *_info);
56 const ShellCommandInfo *info;
57 ShellCommandRegister *next;
76 const char *
prompt()
const {
return prom; }
91 char buffer[SHELL_MAX_CMD_LEN];
107 Shell &operator=(
const Shell &) {
return *
this; }
111 void executeBuiltin(
const char *cmd);
112 void clearCharacters(
size_t len);
113 void changeHistory(
bool up);
134 mutable int currentIndex;
135 mutable size_t currentPosn;
144 inline ShellCommandRegister::ShellCommandRegister(
const ShellCommandInfo *_info)
153 #define ShellCommand(name,help,function) \
154 static char const shell_id_##name[] PROGMEM = #name; \
155 static char const shell_help_##name[] PROGMEM = help; \
156 static ShellCommandInfo const shell_info_##name PROGMEM = { \
161 static ShellCommandRegister shell_cmd_##name(&shell_info_##name)
const char * operator[](int index) const
Gets a specific argument for the command.
virtual void beginSession()
Begins a login session.
void help()
Displays help for all supported commands.
bool begin(Stream &stream, size_t maxHistory=0, Terminal::Mode mode=Serial)
Begin shell handling on an underlying character stream.
virtual void printPrompt()
Prints the current prompt string.
static void registerCommand(ShellCommandRegister *cmd)
Registers a command with the shell.
Operates the terminal in serial mode.
void exit()
Exit from the shell back to the login prompt.
Operates the terminal in telnet mode.
Terminal::Mode mode() const
Returns the mode this terminal is operating in, Serial or Telnet.
void loop()
Performs regular activities on the shell.
void setPrompt(const char *prompt)
Sets the prompt string to display in the shell.
Extended stream interface for terminal operations.
Shell()
Constructs a new Shell instance.
Mode
Mode to operate in, Serial or Telnet.
Stream * stream() const
Returns a pointer to the underlying Stream, or NULL if the stream has not been set with begin() yet...
ShellCommandFunc
Type of functions that provide shell command handlers.
int count() const
Returns the number of arguments, including the name of the command.
const char * prompt() const
Gets the prompt string to display in the shell.
void setUserid(int userid)
Sets the user identifier for the currently logged in user.
virtual void execute()
Executes the command in the buffer.
Convenience class that encapsulates an array of shell command arguments.
Command-line shell access via a login shell.
void end()
Ends shell processing on the underlying stream.
virtual ~Shell()
Destroys this Shell object.
Command-line shell access.
int userid() const
Gets the user identifier for the currently logged in user, or -1 if there is no user logged in curren...