Skip to content

Commit b47ee2d

Browse files
committed
feat(esp_cli_commands): Rename the component to esp_cli_commands
1 parent 8c0e035 commit b47ee2d

32 files changed

+1530
-496
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ body:
3232
- eigen
3333
- esp_daylight
3434
- esp_delta_ota
35-
- esp_commands
35+
- esp_cli_commands
3636
- esp_encrypted_img
3737
- esp_flash_dispatcher
3838
- esp_gcov

.github/workflows/upload_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
dhara
3535
eigen
3636
esp_daylight
37-
esp_commands
37+
esp_cli_commands
3838
esp_delta_ota
3939
esp_encrypted_img
4040
esp_flash_dispatcher

.idf_build_apps.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manifest_file = [
88
"ccomp_timer/.build-test-rules.yml",
99
"coremark/.build-test-rules.yml",
1010
"esp_daylight/.build-test-rules.yml",
11-
"esp_commands/.build-test-rules.yml",
11+
"esp_cli_commands/.build-test-rules.yml",
1212
"esp_encrypted_img/.build-test-rules.yml",
1313
"esp_flash_dispatcher/.build-test-rules.yml",
1414
"esp_gcov/.build-test-rules.yml",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
esp_commands/test_apps:
1+
esp_cli_commands/test_apps:
22
enable:
33
- if: (IDF_TARGET in ["esp32", "linux"]) and (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR >= 3)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
idf_build_get_property(idf_target IDF_TARGET)
22

3-
set(srcs "src/esp_commands.c"
4-
"src/esp_dynamic_commands.c"
5-
"src/esp_commands_helpers.c")
3+
set(srcs "src/esp_cli_commands.c"
4+
"src/esp_cli_dynamic_commands.c"
5+
"src/esp_cli_commands_helpers.c")
66

77
idf_component_register(
88
SRCS ${srcs}
@@ -13,5 +13,5 @@ idf_component_register(
1313

1414
if(${idf_target} STREQUAL "linux")
1515
# Add custom ld file
16-
target_link_options(${COMPONENT_TARGET} INTERFACE "-Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/linux/esp_commands.ld")
16+
target_link_options(${COMPONENT_TARGET} INTERFACE "-Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/linux/esp_cli_commands.ld")
1717
endif()
File renamed without changes.

esp_commands/README.md renamed to esp_cli_commands/README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ESP Commands
22

3-
The `esp_commands` component provides a flexible command registration and execution framework for ESP-IDF applications.
3+
The `esp_cli_commands` component provides a flexible command registration and execution framework for ESP-IDF applications.
44
It allows applications to define console-like commands with metadata (help text, hints, glossary entries) and register them dynamically or statically.
55

66
---
@@ -25,17 +25,17 @@ It allows applications to define console-like commands with metadata (help text,
2525
By default, the component is initialized with a default configuration. It is however possible for the user to update this configuration with the call of the following API:
2626

2727
```c
28-
esp_commands_config_t config = {
28+
esp_cli_commands_config_t config = {
2929
.heap_caps_used = <user specific value>,
3030
.max_cmdline_length = <user specific value>,
3131
.max_cmdline_args = <user specific value>,
3232
.hint_color = <user specific value>,
3333
.hint_bold = <user specific value>
3434
};
35-
esp_commands_update_config(&config);
35+
esp_cli_commands_update_config(&config);
3636
```
3737
38-
- `write_func`: The custom write function used by esp_commands to output data (default to posix write is not specified)
38+
- `write_func`: The custom write function used by esp_cli_commands to output data (default to posix write is not specified)
3939
- `max_cmdline_length`: Maximum command line buffer length (bytes).
4040
- `max_cmdline_args`: Maximum number of arguments parsed.
4141
- `hint_color`: ANSI color code used for hints.
@@ -47,49 +47,49 @@ esp_commands_update_config(&config);
4747
4848
### Command Structure
4949
50-
A command is described by the `esp_command_t` struct:
50+
A command is described by the `esp_cli_command_t` struct:
5151
5252
```c
53-
typedef struct esp_command {
53+
typedef struct esp_cli_command {
5454
const char *name; /*!< Command name */
5555
const char *group; /*!< Group/category */
5656
const char *help; /*!< Short help text */
57-
esp_command_func_t func; /*!< Command implementation */
57+
esp_cli_command_func_t func; /*!< Command implementation */
5858
void *func_ctx; /*!< User context */
59-
esp_command_hint_t hint_cb; /*!< Hint callback */
60-
esp_command_glossary_t glossary_cb; /*!< Glossary callback */
61-
} esp_command_t;
59+
esp_cli_command_hint_t hint_cb; /*!< Hint callback */
60+
esp_cli_command_glossary_t glossary_cb; /*!< Glossary callback */
61+
} esp_cli_command_t;
6262
```
6363

6464
### Static Registration
6565

66-
Use the `ESP_COMMAND_REGISTER` macro to register a command at compile time:
66+
Use the `ESP_CLI_COMMAND_REGISTER` macro to register a command at compile time:
6767

6868
```c
69-
static int my_cmd(void *context, esp_commands_exec_arg_t *cmd_arg, int argc, char **argv) {
69+
static int my_cmd(void *context, esp_cli_commands_exec_arg_t *cmd_arg, int argc, char **argv) {
7070
printf("Hello from my_cmd!\n");
7171
return 0;
7272
}
7373

74-
ESP_COMMAND_REGISTER(my_cmd, tools, "Prints hello", my_cmd, NULL, NULL, NULL);
74+
ESP_CLI_COMMAND_REGISTER(my_cmd, tools, "Prints hello", my_cmd, NULL, NULL, NULL);
7575
```
7676
77-
This places the command into the `.esp_commands` section in flash.
77+
This places the command into the `.esp_cli_commands` section in flash.
7878
7979
### Dynamic Registration
8080
8181
Commands can also be registered/unregistered at runtime:
8282
8383
```c
84-
esp_command_t cmd = {
84+
esp_cli_command_t cmd = {
8585
.name = "my_cmd",
8686
.group = "tools",
8787
.help = "Prints hello",
8888
.func = my_cmd,
8989
};
9090
91-
esp_commands_register_cmd(&cmd);
92-
esp_commands_unregister_cmd("echo");
91+
esp_cli_commands_register_cmd(&cmd);
92+
esp_cli_commands_unregister_cmd("echo");
9393
```
9494

9595
---
@@ -100,7 +100,7 @@ Commands can be executed from a command line string:
100100

101101
```c
102102
int cmd_ret;
103-
esp_err_t ret = esp_commands_execute("my_cmd arg1 arg2", &cmd_ret, NULL, STDOUT_FILENO);
103+
esp_err_t ret = esp_cli_commands_execute("my_cmd arg1 arg2", &cmd_ret, NULL, STDOUT_FILENO);
104104
```
105105

106106
- `cmd_set`: Limits execution to a set of commands (or `NULL` for all commands).
@@ -115,9 +115,9 @@ esp_err_t ret = esp_commands_execute("my_cmd arg1 arg2", &cmd_ret, NULL, STDOUT_
115115
Completion & Help APIs:
116116

117117
```c
118-
esp_commands_get_completion(NULL, "ec", completion_cb);
119-
const char *hint = esp_commands_get_hint(NULL, "echo", &color, &bold);
120-
const char *glossary = esp_commands_get_glossary(NULL, "echo");
118+
esp_cli_commands_get_completion(NULL, "ec", completion_cb);
119+
const char *hint = esp_cli_commands_get_hint(NULL, "echo", &color, &bold);
120+
const char *glossary = esp_cli_commands_get_glossary(NULL, "echo");
121121
```
122122
123123
- **Completion**: Suggests matching commands.
@@ -132,15 +132,15 @@ Command sets allow grouping subsets of commands for filtering:
132132
133133
```c
134134
const char *cmd_names[] = {"echo", "my_cmd"};
135-
esp_command_set_handle_t set =
136-
ESP_COMMANDS_CREATE_CMD_SET(cmd_names, FIELD_ACCESSOR(name));
135+
esp_cli_command_set_handle_t set =
136+
ESP_CLI_COMMANDS_CREATE_CMD_SET(cmd_names, ESP_CLI_COMMAND_FIELD_ACCESSOR(name));
137137
138-
esp_commands_execute("my_cmd", NULL, set, NULL);
139-
esp_commands_destroy_cmd_set(&set);
138+
esp_cli_commands_execute("my_cmd", NULL, set, NULL);
139+
esp_cli_commands_destroy_cmd_set(&set);
140140
```
141141

142142
- Create sets by name, group, or other fields.
143-
- Concatenate sets with `esp_commands_concat_cmd_set()`.
143+
- Concatenate sets with `esp_cli_commands_concat_cmd_set()`.
144144
- Destroy sets when no longer needed.
145145

146146
---
@@ -149,7 +149,7 @@ esp_commands_destroy_cmd_set(&set);
149149

150150
```c
151151
#include <stdio.h>
152-
#include "esp_commands.h"
152+
#include "esp_cli_commands.h"
153153

154154
// Example command function
155155
static int hello_cmd(void *ctx, int argc, char **argv) {
@@ -158,22 +158,22 @@ static int hello_cmd(void *ctx, int argc, char **argv) {
158158
}
159159

160160
// Register command statically
161-
ESP_COMMAND_REGISTER(hello_cmd, demo, "Prints a hello message", hello_cmd, NULL, NULL, NULL);
161+
ESP_CLI_COMMAND_REGISTER(hello_cmd, demo, "Prints a hello message", hello_cmd, NULL, NULL, NULL);
162162

163163
void app_main(void) {
164164
// Update configuration (optional)
165-
esp_commands_config_t config = {
165+
esp_cli_commands_config_t config = {
166166
.heap_caps_used = MALLOC_CAP_INTERNAL,
167167
.max_cmdline_length = 64,
168168
.max_cmdline_args = 4,
169169
.hint_color = 31, // Red foreground
170170
.hint_bold = true
171171
};
172-
esp_commands_update_config(&config);
172+
esp_cli_commands_update_config(&config);
173173

174174
// Execute command
175175
int ret_val;
176-
esp_err_t ret = esp_commands_execute("hello_cmd", &ret_val, NULL, NULL);
176+
esp_err_t ret = esp_cli_commands_execute("hello_cmd", &ret_val, NULL, NULL);
177177
if (ret == ESP_OK) {
178178
printf("Command executed successfully, return value: %d\n", ret_val);
179179
} else {
@@ -186,10 +186,10 @@ void app_main(void) {
186186
187187
## API Reference
188188
189-
- **Configuration**: `esp_commands_update_config()`
190-
- **Registration**: `esp_commands_register_cmd()`, `esp_commands_unregister_cmd()`
191-
- **Execution**: `esp_commands_execute()`, `esp_commands_find_command()`
192-
- **Completion & Help APIs**: `esp_commands_get_completion()`, `esp_commands_get_hint()`, `esp_commands_get_glossary()`
193-
- **Command Sets**: `esp_commands_create_cmd_set()`, `esp_commands_concat_cmd_set()`, `esp_commands_destroy_cmd_set()`
189+
- **Configuration**: `esp_cli_commands_update_config()`
190+
- **Registration**: `esp_cli_commands_register_cmd()`, `esp_cli_commands_unregister_cmd()`
191+
- **Execution**: `esp_cli_commands_execute()`, `esp_cli_commands_find_command()`
192+
- **Completion & Help APIs**: `esp_cli_commands_get_completion()`, `esp_cli_commands_get_hint()`, `esp_cli_commands_get_glossary()`
193+
- **Command Sets**: `esp_cli_commands_create_cmd_set()`, `esp_cli_commands_concat_cmd_set()`, `esp_cli_commands_destroy_cmd_set()`
194194
195195
---
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
version: "0.1.0"
2-
description: "esp_commands - Command handling component"
3-
url: https://github.com/espressif/idf-extra-components/tree/master/esp_commands
2+
description: "esp_cli_commands - Command handling component"
3+
url: https://github.com/espressif/idf-extra-components/tree/master/esp_cli_commands
44
dependencies:
55
idf: ">=5.3"
66
sbom:
77
manifests:
8-
- path: sbom_esp_commands.yml
8+
- path: sbom_esp_cli_commands.yml
99
dest: .

0 commit comments

Comments
 (0)