Simple embedded shell with runtime pluggable commands.
Implements a simple unix-like shell for embedded systems with a pluggable command architecture.
Diff: SimpleShell.h
- Revision:
- 15:242626d8d104
- Parent:
- 14:75b5918090ae
- Child:
- 16:f2b9b7b2c71e
--- a/SimpleShell.h Wed Dec 19 00:29:05 2018 +0000 +++ b/SimpleShell.h Wed Dec 19 18:25:12 2018 +0000 @@ -20,6 +20,10 @@ */ class SimpleShell { public: + + /// Callback type used for shell commands + typedef Callback<void(int, char**)> callback_t; + /// Create a new shell instance SimpleShell(); @@ -40,7 +44,7 @@ * sh.attach(helloworld, "test"); * @endcode */ - void attach(Callback<void()> cb, char *command); + void attach(callback_t cb, char *command); private: @@ -53,19 +57,19 @@ /// internal struct to contain a single command typedef struct { char *command; - Callback<void()> cb; + callback_t cb; } command_entry_t; /** finds and eturns the callback for a command * @return Callback to a function returning void */ - Callback<void()> findCommand(); + callback_t findCommand(); /// Built-in shell command to display list of commands - void help(); + void help(int argc, char **argv); /// Built-in shell command to print working directory - void pwd(); + void pwd(int argc, char **argv); /// Prints command prompt void printPrompt(void); @@ -80,7 +84,7 @@ int lookupEnd; /// Maximum number of arguments - static const int MAXARGS=5; + static const int MAXARGS=3; /// Command and arguments char *argv[MAXARGS];