30#include <esp_console.h>
51using handler = std::move_only_function<int(
int argc,
char** argv)>;
62 std::string_view
help = {};
63 std::string_view
hint = {};
71#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
184#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
225int run(std::string_view cmdline);
308#if CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM || defined(__DOXYGEN__)
310 static constexpr uart_port default_uart_port =
static_cast<uart_port>(CONFIG_ESP_CONSOLE_UART_NUM);
317 int baud_rate = CONFIG_ESP_CONSOLE_UART_BAUDRATE;
318 gpio tx_gpio = gpio::nc();
319 gpio rx_gpio = gpio::nc();
322#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
337 [[nodiscard]]
explicit repl(
const config& cfg,
const uart_config& uart);
356#if CONFIG_ESP_CONSOLE_USB_CDC || (defined(__DOXYGEN__) && SOC_USB_OTG_SUPPORTED)
360 struct usb_cdc_config {};
362#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
373 [[nodiscard]]
explicit repl(
const config& cfg,
const usb_cdc_config& usb_cdc);
385 [[nodiscard]]
static result<repl> make(
const config& cfg,
const usb_cdc_config& usb_cdc);
392#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || (defined(__DOXYGEN__) && SOC_USB_SERIAL_JTAG_SUPPORTED)
396 struct usb_serial_jtag_config {};
398#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
409 [[nodiscard]]
explicit repl(
const config& cfg,
const usb_serial_jtag_config& usb_jtag);
Interactive REPL (Read-Eval-Print Loop) console.
esp_console_repl_t * idf_handle() const noexcept
Returns the underlying ESP-IDF REPL handle.
repl(repl &&other) noexcept
Move constructor.
repl(const repl &)=delete
~repl()
Destroys the REPL.
repl & operator=(const repl &)=delete
repl & operator=(repl &&other) noexcept
Move assignment.
Type-safe wrapper for FreeRTOS task priority values.
result< void > try_deinit()
Deinitializes the console module.
result< void > try_deregister_command(std::string_view name)
Deregisters a previously registered command.
void deinit()
Deinitializes the console module.
std::move_only_function< int(int argc, char **argv)> handler
Command handler callback type.
result< int > try_run(std::string_view cmdline)
Runs a command line string.
result< void > try_register_help_command()
Registers the built-in 'help' command.
void register_command(const command &cmd, handler callback)
Registers a command with a callback handler.
int run(std::string_view cmdline)
Runs a command line string.
void register_help_command()
Registers the built-in 'help' command.
void init(const config &cfg={})
Initializes the console module.
void deregister_help_command()
Deregisters the built-in 'help' command.
result< void > try_init(const config &cfg={})
Initializes the console module.
result< void > try_deregister_help_command()
Deregisters the built-in 'help' command.
void deregister_command(std::string_view name)
Deregisters a previously registered command.
result< void > try_register_command(const command &cmd, handler callback)
Registers a command with a callback handler.
uart_port
Identifies a UART port.
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Command descriptor for registration.
std::string_view hint
Hint text (empty = auto-generate from argtable)
void * argtable
Optional argtable3 pointer for argument parsing.
std::string_view help
Help text (empty = hidden from help)
std::string_view name
Command name (required, no spaces)
Configuration for low-level console initialization.
size_t max_cmdline_length
Maximum command line length in bytes.
int hint_color
ASCII color code for hint text.
bool hint_bold
Whether to display hints in bold.
size_t max_cmdline_args
Maximum number of command line arguments.
REPL configuration parameters.
std::string_view prompt
Prompt string (empty = default "esp> ")
std::optional< core_id > core_affinity
Core affinity (nullopt = any core)
size_t max_history_len
Maximum command history length.
size_t max_cmdline_length
Maximum command line length (0 = default 256)
size_t task_stack_size
REPL task stack size in bytes.
task_priority priority
REPL task priority.
std::filesystem::path history_save_path
File path for history persistence (empty = no save)