jtag: rewrite command 'jtag names' as COMMAND_HANDLER

While there:
- format in a human readable way the output list by using one line
  per tap name;
- add the mandatory 'usage' field.

Change-Id: I295449220c78fac8973478b265413342ea832f61
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7494
Tested-by: jenkins
This commit is contained in:
Antonio Borneo 2022-12-19 18:08:03 +01:00
parent 19e2a0d6af
commit 2774125257
1 changed files with 9 additions and 17 deletions

View File

@ -805,24 +805,15 @@ int jim_jtag_configure(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return jtag_tap_configure_cmd(&goi, t);
}
static int jim_jtag_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
COMMAND_HANDLER(handle_jtag_names)
{
struct jim_getopt_info goi;
jim_getopt_setup(&goi, interp, argc-1, argv + 1);
if (goi.argc != 0) {
Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters");
return JIM_ERR;
}
Jim_SetResult(goi.interp, Jim_NewListObj(goi.interp, NULL, 0));
struct jtag_tap *tap;
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
for (tap = jtag_all_taps(); tap; tap = tap->next_tap) {
Jim_ListAppendElement(goi.interp,
Jim_GetResult(goi.interp),
Jim_NewStringObj(goi.interp,
tap->dotted_name, -1));
}
return JIM_OK;
for (struct jtag_tap *tap = jtag_all_taps(); tap; tap = tap->next_tap)
command_print(CMD, "%s", tap->dotted_name);
return ERROR_OK;
}
COMMAND_HANDLER(handle_jtag_init_command)
@ -921,8 +912,9 @@ static const struct command_registration jtag_subcommand_handlers[] = {
{
.name = "names",
.mode = COMMAND_ANY,
.jim_handler = jim_jtag_names,
.handler = handle_jtag_names,
.help = "Returns list of all JTAG tap names.",
.usage = "",
},
{
.chain = jtag_command_handlers_to_move,