Simple embedded shell with runtime pluggable commands.
Implements a simple unix-like shell for embedded systems with a pluggable command architecture.
Diff: SimpleShell.cpp
- Revision:
- 4:8b8fa59d0015
- Parent:
- 3:ebb4893f033d
- Child:
- 5:8f486f4d29d3
diff -r ebb4893f033d -r 8b8fa59d0015 SimpleShell.cpp --- a/SimpleShell.cpp Sun Dec 02 17:14:28 2018 +0000 +++ b/SimpleShell.cpp Sun Dec 02 17:20:15 2018 +0000 @@ -8,17 +8,21 @@ void SimpleShell::run() { bool done=false; + Callback<void()> cb; + strcpy(_cwd, "/log"); printf("Type help for assistance.\n"); while (!done) { printPrompt(); readCommand(); - //cb = findCommand(); - //if cb - // status = cb.call(); - // done = status == EXIT - //else error not found + if (cb = findCommand()) { + printf("found\n"); + // status = cb.call(); + // done = status == EXIT + } else { + printf("command not found\n"); + } } puts("exiting shell\n"); @@ -46,6 +50,13 @@ { Callback<void()> cb=NULL; + for (int i=0; i < lookupEnd; i++) { + if (strncmp(cmd, lookup[i].command, MAXBUF) == 0) { + cb = lookup[i].cb; + break; + } + } + return cb; }