JIM: document "echo" command
Document "-n" option in manual; Modify "echo" command definition as COMMAND_HANDLER to easily add help message Add help message aligned with manual. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>__archive__
parent
d220e22e63
commit
4747af362d
|
@ -5446,9 +5446,10 @@ file (which is normally the server's standard output).
|
||||||
@xref{Running}.
|
@xref{Running}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn Command echo message
|
@deffn Command echo [-n] message
|
||||||
Logs a message at "user" priority.
|
Logs a message at "user" priority.
|
||||||
Output @var{message} to stdout.
|
Output @var{message} to stdout.
|
||||||
|
Option "-n" suppresses trailing newline.
|
||||||
@example
|
@example
|
||||||
echo "Downloading kernel -- please wait"
|
echo "Downloading kernel -- please wait"
|
||||||
@end example
|
@end example
|
||||||
|
|
|
@ -777,19 +777,16 @@ static int jim_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||||
return JIM_OK;
|
return JIM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
COMMAND_HANDLER(jim_echo)
|
||||||
{
|
{
|
||||||
const char *str;
|
if (CMD_ARGC == 2 && !strcmp(CMD_ARGV[0], "-n"))
|
||||||
str = Jim_GetString(argv[1], NULL);
|
|
||||||
if (argc == 3 && !strcmp(str, "-n"))
|
|
||||||
{
|
{
|
||||||
str = Jim_GetString(argv[2], NULL);
|
LOG_USER_N("%s", CMD_ARGV[1]);
|
||||||
LOG_USER_N("%s", str);
|
|
||||||
return JIM_OK;
|
return JIM_OK;
|
||||||
}
|
}
|
||||||
if (argc != 2)
|
if (CMD_ARGC != 1)
|
||||||
return JIM_ERR;
|
return JIM_ERR;
|
||||||
LOG_USER("%s", str);
|
LOG_USER("%s", CMD_ARGV[0]);
|
||||||
return JIM_OK;
|
return JIM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1261,6 +1258,15 @@ static const struct command_registration command_subcommand_handlers[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct command_registration command_builtin_handlers[] = {
|
static const struct command_registration command_builtin_handlers[] = {
|
||||||
|
{
|
||||||
|
.name = "echo",
|
||||||
|
.handler = jim_echo,
|
||||||
|
.mode = COMMAND_ANY,
|
||||||
|
.help = "Logs a message at \"user\" priority. "
|
||||||
|
"Output message to stdout. "
|
||||||
|
"Option \"-n\" suppresses trailing newline",
|
||||||
|
.usage = "[-n] string",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "add_help_text",
|
.name = "add_help_text",
|
||||||
.handler = handle_help_add_command,
|
.handler = handle_help_add_command,
|
||||||
|
@ -1364,7 +1370,6 @@ struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp
|
||||||
Jim_NewStringObj(interp, HostOs , strlen(HostOs)));
|
Jim_NewStringObj(interp, HostOs , strlen(HostOs)));
|
||||||
|
|
||||||
Jim_CreateCommand(interp, "ocd_find", jim_find, NULL, NULL);
|
Jim_CreateCommand(interp, "ocd_find", jim_find, NULL, NULL);
|
||||||
Jim_CreateCommand(interp, "echo", jim_echo, NULL, NULL);
|
|
||||||
Jim_CreateCommand(interp, "capture", jim_capture, NULL, NULL);
|
Jim_CreateCommand(interp, "capture", jim_capture, NULL, NULL);
|
||||||
|
|
||||||
register_commands(context, NULL, command_builtin_handlers);
|
register_commands(context, NULL, command_builtin_handlers);
|
||||||
|
|
Loading…
Reference in New Issue