AceRoutine  0.2
A low-memory, fast-switching, cooperative multitasking library using stackless coroutines on Arduino platforms.
Public Member Functions | Protected Member Functions | List of all members
ace_routine::cli::CommandHandler Class Referenceabstract

Signature for a command handler. More...

#include <CommandHandler.h>

Public Member Functions

virtual void run (Print &printer, int argc, const char **argv) const =0
 Run the command. More...
 
FCString getName () const
 Return the name of the command. More...
 
FCString getHelpString () const
 Return the help string of the command. More...
 

Protected Member Functions

 CommandHandler (const char *name, const char *helpString)
 Constructor. More...
 
 CommandHandler (const __FlashStringHelper *name, const __FlashStringHelper *helpString)
 Constructor. More...
 

Detailed Description

Signature for a command handler.

Definition at line 38 of file CommandHandler.h.

Constructor & Destructor Documentation

◆ CommandHandler() [1/2]

ace_routine::cli::CommandHandler::CommandHandler ( const char *  name,
const char *  helpString 
)
inlineprotected

Constructor.

Using C strings.

Definition at line 65 of file CommandHandler.h.

◆ CommandHandler() [2/2]

ace_routine::cli::CommandHandler::CommandHandler ( const __FlashStringHelper *  name,
const __FlashStringHelper *  helpString 
)
inlineprotected

Constructor.

Using Flash strings.

Definition at line 70 of file CommandHandler.h.

Member Function Documentation

◆ getHelpString()

FCString ace_routine::cli::CommandHandler::getHelpString ( ) const
inline

Return the help string of the command.

Definition at line 61 of file CommandHandler.h.

◆ getName()

FCString ace_routine::cli::CommandHandler::getName ( ) const
inline

Return the name of the command.

Definition at line 58 of file CommandHandler.h.

◆ run()

virtual void ace_routine::cli::CommandHandler::run ( Print &  printer,
int  argc,
const char **  argv 
) const
pure virtual

Run the command.

Parameters
printerThe output printer, normally Serial. This is not expected to change during the lifetime of the CommandHandler instance, so normally I would inject this parameter into the object. However, that would cause each instance to consume 2 more bytes, even though all instances are expected to have the same 'printer'. For an 8-bit AVR processor with only 2kB of RAM, every byte is important , so I am keeping this as a parameter passed into the run() method.
argcNumber of tokens in the input command, including the name of the command itself.
argvAn array of strings for each token.

The documentation for this class was generated from the following file: