Skip to content

Commit

Permalink
Move CommandProcessing into Libraries (#2740)
Browse files Browse the repository at this point in the history
Since the `CommandProcessing` library is entirely optional and not a core dependency for Sming, move it into `Libraries`.

Also fix a few naming inconsistencies, comments and remove outdated documentation.
  • Loading branch information
mikee47 authored Mar 21, 2024
1 parent a7d3862 commit ffe12d6
Show file tree
Hide file tree
Showing 38 changed files with 17 additions and 108 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ void Handler::processCommandLine(const String& cmdString)
void Handler::registerSystemCommands()
{
String system = F("system");
registerCommand({F("status"), F("Displays System Information"), system, {&Handler::procesStatusCommand, this}});
registerCommand({F("echo"), F("Displays command entered"), system, {&Handler::procesEchoCommand, this}});
registerCommand({F("help"), F("Displays all available commands"), system, {&Handler::procesHelpCommand, this}});
registerCommand({F("debugon"), F("Set Serial debug on"), system, {&Handler::procesDebugOnCommand, this}});
registerCommand({F("debugoff"), F("Set Serial debug off"), system, {&Handler::procesDebugOffCommand, this}});
registerCommand({F("status"), F("Displays System Information"), system, {&Handler::processStatusCommand, this}});
registerCommand({F("echo"), F("Displays command entered"), system, {&Handler::processEchoCommand, this}});
registerCommand({F("help"), F("Displays all available commands"), system, {&Handler::processHelpCommand, this}});
registerCommand({F("debugon"), F("Set Serial debug on"), system, {&Handler::processDebugOnCommand, this}});
registerCommand({F("debugoff"), F("Set Serial debug off"), system, {&Handler::processDebugOffCommand, this}});
registerCommand({F("command"),
F("Use verbose/silent/prompt as command options"),
system,
Expand Down Expand Up @@ -143,7 +143,7 @@ bool Handler::unregisterCommand(Command reqDelegate)
}
}

void Handler::procesHelpCommand(String commandLine, ReadWriteStream& outputStream)
void Handler::processHelpCommand(String commandLine, ReadWriteStream& outputStream)
{
debug_d("HelpCommand entered");
outputStream.println(_F("Commands available are :"));
Expand All @@ -152,7 +152,7 @@ void Handler::procesHelpCommand(String commandLine, ReadWriteStream& outputStrea
}
}

void Handler::procesStatusCommand(String commandLine, ReadWriteStream& outputStream)
void Handler::processStatusCommand(String commandLine, ReadWriteStream& outputStream)
{
debug_d("StatusCommand entered");
outputStream << _F("Sming Framework Version : " SMING_VERSION) << endl;
Expand All @@ -161,19 +161,19 @@ void Handler::procesStatusCommand(String commandLine, ReadWriteStream& outputStr
outputStream << _F("System Start Reason : ") << system_get_rst_info()->reason << endl;
}

void Handler::procesEchoCommand(String commandLine, ReadWriteStream& outputStream)
void Handler::processEchoCommand(String commandLine, ReadWriteStream& outputStream)
{
debug_d("HelpCommand entered");
outputStream << _F("You entered : '") << commandLine << '\'' << endl;
}

void Handler::procesDebugOnCommand(String commandLine, ReadWriteStream& outputStream)
void Handler::processDebugOnCommand(String commandLine, ReadWriteStream& outputStream)
{
// Serial.systemDebugOutput(true);
// outputStream.println(_F("Debug set to : On"));
}

void Handler::procesDebugOffCommand(String commandLine, ReadWriteStream& outputStream)
void Handler::processDebugOffCommand(String commandLine, ReadWriteStream& outputStream)
{
// Serial.systemDebugOutput(false);
// outputStream.println(_F("Debug set to : Off"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Handler
*/
void setOutputStream(ReadWriteStream* stream, bool owned = true)
{
if(outputStream != nullptr && ownedStream) {
if(ownedStream) {
delete outputStream;
}

Expand Down Expand Up @@ -125,7 +125,7 @@ class Handler

/** @brief Get the command delegate for a command
* @param commandString Command to query
* @retval CommandDelegate The command delegate matching the command
* @retval Command The command delegate matching the command
*/
Command getCommandDelegate(const String& commandString);

Expand Down Expand Up @@ -217,11 +217,11 @@ class Handler
bool ownedStream = true;
LineBuffer<MAX_COMMANDSIZE + 1> commandBuf;

void procesHelpCommand(String commandLine, ReadWriteStream& outputStream);
void procesStatusCommand(String commandLine, ReadWriteStream& outputStream);
void procesEchoCommand(String commandLine, ReadWriteStream& outputStream);
void procesDebugOnCommand(String commandLine, ReadWriteStream& outputStream);
void procesDebugOffCommand(String commandLine, ReadWriteStream& outputStream);
void processHelpCommand(String commandLine, ReadWriteStream& outputStream);
void processStatusCommand(String commandLine, ReadWriteStream& outputStream);
void processEchoCommand(String commandLine, ReadWriteStream& outputStream);
void processDebugOnCommand(String commandLine, ReadWriteStream& outputStream);
void processDebugOffCommand(String commandLine, ReadWriteStream& outputStream);
void processCommandOptions(String commandLine, ReadWriteStream& outputStream);

void processCommandLine(const String& cmdString);
Expand Down
90 changes: 0 additions & 90 deletions docs/source/information/command-handler.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/information/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ Information
tasks
debugging
rboot-ota
command-handler
tips-n-tricks

0 comments on commit ffe12d6

Please sign in to comment.