Simple embedded shell with runtime pluggable commands.

Dependents:   DataBus2018

Implements a simple unix-like shell for embedded systems with a pluggable command architecture.

Revision:
6:4da092220ba8
Parent:
4:8b8fa59d0015
Child:
7:b58450c94d32
--- a/SimpleShell.h	Sun Dec 02 17:33:07 2018 +0000
+++ b/SimpleShell.h	Wed Dec 12 17:46:29 2018 +0000
@@ -1,20 +1,36 @@
+#ifndef __SIMPLESHELL_H
+#define __SIMPLESHELL_H
+
 #include "mbed.h"
 
-typedef struct {
-    char *command;
-    Callback<void()> cb;
-} command_entry_t;
-
-
+/** SimpleShell
+ *  A simple, flexible, embedded shell with dynamically added shell commands.
+ */
 class SimpleShell {
 public:  
+    /// Create a new shell instance
     SimpleShell();
 
+    /// Call this to run the shell in a thread
     void run();
+
+    /** Attaches a shell command
+     * @param cb is the callback function that implements the command
+     * @param command is the string used to invoke the command in the shell
+     */
     void attach(Callback<void()> cb, char *command);
+
+    /** finds and eturns the callback for a command
+     * @return Callback to a function returning void
+     */
     Callback<void()> findCommand();  
     
 private:
+    typedef struct {
+        char *command;
+        Callback<void()> cb;
+    } command_entry_t;
+
     static const int MAXBUF=32;
     static const int MAXLOOKUP=32;
     void printPrompt(void);
@@ -23,4 +39,6 @@
     int lookupEnd;
     char cmd[MAXBUF];
     char _cwd[MAXBUF];
-}; // class
\ No newline at end of file
+}; // class
+
+#endif
\ No newline at end of file