diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2022-12-19 23:54:10 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2023-03-25 18:15:43 +0000 |
commit | d9d698103e974b2a94c611864cccb92359509b7d (patch) | |
tree | d89293455f0b532cd0fc5a10c290ac1ee92f8a99 | |
parent | 26f457896c456c57a57719e484d055d444ba67ee (diff) | |
download | riscv-openocd-d9d698103e974b2a94c611864cccb92359509b7d.zip riscv-openocd-d9d698103e974b2a94c611864cccb92359509b7d.tar.gz riscv-openocd-d9d698103e974b2a94c611864cccb92359509b7d.tar.bz2 |
target: rewrite command 'target types' as COMMAND_HANDLER
Print one entry per line.
While there add the mandatory 'usage' field.
Change-Id: I135556e12154e33fdbd0f71d89f6fe37c69813b7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7509
Tested-by: jenkins
-rw-r--r-- | src/target/target.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/target/target.c b/src/target/target.c index ae5f74c..b77a25a 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -6377,18 +6377,15 @@ COMMAND_HANDLER(handle_target_current) return ERROR_OK; } -static int jim_target_types(Jim_Interp *interp, int argc, Jim_Obj *const *argv) +COMMAND_HANDLER(handle_target_types) { - if (argc != 1) { - Jim_WrongNumArgs(interp, 1, argv, "Too many parameters"); - return JIM_ERR; - } - Jim_SetResult(interp, Jim_NewListObj(interp, NULL, 0)); - for (unsigned x = 0; target_types[x]; x++) { - Jim_ListAppendElement(interp, Jim_GetResult(interp), - Jim_NewStringObj(interp, target_types[x]->name, -1)); - } - return JIM_OK; + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + for (unsigned int x = 0; target_types[x]; x++) + command_print(CMD, "%s", target_types[x]->name); + + return ERROR_OK; } static int jim_target_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv) @@ -6526,9 +6523,10 @@ static const struct command_registration target_subcommand_handlers[] = { { .name = "types", .mode = COMMAND_ANY, - .jim_handler = jim_target_types, + .handler = handle_target_types, .help = "Returns the available target types as " "a list of strings", + .usage = "", }, { .name = "names", |