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:
- 2:4f0affdb7db9
- Parent:
- 1:998a7ed04f10
- Child:
- 3:ebb4893f033d
--- a/SimpleShell.cpp Sun Dec 02 16:50:40 2018 +0000 +++ b/SimpleShell.cpp Sun Dec 02 17:09:08 2018 +0000 @@ -2,6 +2,7 @@ SimpleShell::SimpleShell() { + lookupEnd = 0; } void SimpleShell::run() @@ -21,7 +22,19 @@ } -void SimpleShell::attach(Callback<void()> cb, char *command) { +void SimpleShell::attach(Callback<void()> cb, char *command) +{ + if (lookupEnd < MAXLOOKUP) { + lookup[lookupEnd].cb = cb; + lookup[lookupEnd].command = command; + lookupEnd++; + } + + for (int i=0; i < lookupEnd; i++) { + printf("%s\n", lookup[i].command); + } + + return; } @@ -30,6 +43,8 @@ fputc('(', stdout); fputs(_cwd, stdout); fputs(")# ", stdout); + + return; } @@ -60,5 +75,5 @@ } while (!done); fputc('\n', stdout); - + return; } \ No newline at end of file