|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Interactive console with REPL and command registration. More...
Namespaces | |
| namespace | idfxx |
| namespace | idfxx::console |
Classes | |
| struct | idfxx::console::command |
| Command descriptor for registration. More... | |
| struct | idfxx::console::config |
| Configuration for low-level console initialization. More... | |
| class | idfxx::console::repl |
| Interactive REPL (Read-Eval-Print Loop) console. More... | |
Typedefs | |
| using | idfxx::console::handler = std::move_only_function< int(int argc, char **argv)> |
| Command handler callback type. | |
Functions | |
| void | idfxx::console::register_command (const command &cmd, handler callback) |
| Registers a command with a callback handler. | |
| void | idfxx::console::deregister_command (std::string_view name) |
| Deregisters a previously registered command. | |
| void | idfxx::console::register_help_command () |
| Registers the built-in 'help' command. | |
| void | idfxx::console::deregister_help_command () |
| Deregisters the built-in 'help' command. | |
| result< void > | idfxx::console::try_register_command (const command &cmd, handler callback) |
| Registers a command with a callback handler. | |
| result< void > | idfxx::console::try_deregister_command (std::string_view name) |
| Deregisters a previously registered command. | |
| result< void > | idfxx::console::try_register_help_command () |
| Registers the built-in 'help' command. | |
| result< void > | idfxx::console::try_deregister_help_command () |
| Deregisters the built-in 'help' command. | |
| void | idfxx::console::init (const config &cfg={}) |
| Initializes the console module. | |
| void | idfxx::console::deinit () |
| Deinitializes the console module. | |
| int | idfxx::console::run (std::string_view cmdline) |
| Runs a command line string. | |
| result< void > | idfxx::console::try_init (const config &cfg={}) |
| Initializes the console module. | |
| result< void > | idfxx::console::try_deinit () |
| Deinitializes the console module. | |
| result< int > | idfxx::console::try_run (std::string_view cmdline) |
| Runs a command line string. | |
Interactive console with REPL and command registration.
Provides an interactive command-line console for ESP32 devices, supporting UART, USB CDC, and USB Serial JTAG backends. Commands can be registered with C++ callbacks (including lambdas with captures) or raw function pointers.
The console uses a global command registry – commands registered via the free functions in this namespace are available across all backends.
Depends on Core Utilities for error handling.
Command handler callback type.
Called when a registered command is executed. The callback receives the argument count and argument vector, and returns an integer status code (0 for success).
Definition at line 51 of file console.hpp.
| void idfxx::console::deinit | ( | ) |
Deinitializes the console module.
| std::system_error | on failure. |
| void idfxx::console::deregister_command | ( | std::string_view | name | ) |
Deregisters a previously registered command.
| name | The command name to deregister. |
| std::system_error | on failure. |
| void idfxx::console::deregister_help_command | ( | ) |
Deregisters the built-in 'help' command.
| std::system_error | on failure. |
Initializes the console module.
Call this before using command registration or run() in non-REPL mode. Not needed when using the REPL, which initializes the console internally.
| cfg | Console configuration. |
| std::system_error | on failure. |
Registers a command with a callback handler.
The callback can be any callable, including lambdas with captures and raw function pointers. The callback and command strings are stored internally and remain valid until the command is deregistered or the console is deinitialized.
| cmd | Command descriptor. |
| callback | Function to call when the command is executed. |
| std::system_error | on failure. |
| void idfxx::console::register_help_command | ( | ) |
Registers the built-in 'help' command.
The help command lists all registered commands with their help text.
| std::system_error | on failure. |
| int idfxx::console::run | ( | std::string_view | cmdline | ) |
Runs a command line string.
Parses and executes the given command line. The console must be initialized first via init() or by creating a REPL.
| cmdline | The command line string to execute. |
| std::system_error | if the command is not found or the console is not initialized. |
Deinitializes the console module.
| invalid_state | If not initialized. |
Deregisters a previously registered command.
| name | The command name to deregister. |
| invalid_arg | If the command is not registered. |
Deregisters the built-in 'help' command.
Initializes the console module.
Call this before using command registration or try_run() in non-REPL mode. Not needed when using the REPL, which initializes the console internally.
| cfg | Console configuration. |
| invalid_state | If already initialized. |
| invalid_arg | If the configuration is invalid. |
Registers a command with a callback handler.
The callback can be any callable, including lambdas with captures and raw function pointers. The callback and command strings are stored internally and remain valid until the command is deregistered or the console is deinitialized.
| cmd | Command descriptor. |
| callback | Function to call when the command is executed. |
| invalid_arg | If the command name is empty or contains spaces. |
Registers the built-in 'help' command.
The help command lists all registered commands with their help text.
| invalid_state | If the console is not initialized. |
Runs a command line string.
Parses and executes the given command line. The console must be initialized first via try_init() or by creating a REPL.
| cmdline | The command line string to execute. |
| invalid_arg | If the command line is empty or only whitespace. |
| not_found | If the command is not registered. |
| invalid_state | If the console is not initialized. |