Skip to content

Commit

Permalink
server/telnet: Restructure commands
Browse files Browse the repository at this point in the history
Use a command group 'telnet' with subcommands instead of individual
commands with 'telnet_' prefix. Even though there is only one subcommand
at the moment, make this change to ensure consistency with other commands.

The old command is still available to ensure backwards compatibility,
but are marked as deprecated.

Change-Id: I5e88632fa0d0ce5a8129e9fcf5ae743fc5b093cb
Signed-off-by: Marc Schink <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/8378
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
  • Loading branch information
zapb-0 authored and borneoa committed Sep 21, 2024
1 parent e6ade35 commit ad21613
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ the port @var{number} defaults to 6666.
When specified as "disabled", this service is not activated.
@end deffn

@deffn {Config Command} {telnet_port} [number]
@deffn {Config Command} {telnet port} [number]
Specify or query the
port on which to listen for incoming telnet connections.
This port is intended for interaction with one human through TCL commands.
Expand Down
6 changes: 6 additions & 0 deletions src/server/startup.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,9 @@ proc "tcl_trace" {state} {
echo "DEPRECATED! use 'tcl trace' not 'tcl_trace'"
eval tcl trace $state
}

lappend _telnet_autocomplete_skip "telnet_port"
proc "telnet_port" {args} {
echo "DEPRECATED! use 'telnet port', not 'telnet_port'"
eval telnet port $args
}
24 changes: 17 additions & 7 deletions src/server/telnet_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,6 @@ int telnet_init(char *banner)
return ERROR_OK;
}

/* daemon configuration command telnet_port */
COMMAND_HANDLER(handle_telnet_port_command)
{
return CALL_COMMAND_HANDLER(server_pipe_command, &telnet_port);
Expand All @@ -978,6 +977,19 @@ COMMAND_HANDLER(handle_exit_command)
return ERROR_COMMAND_CLOSE_CONNECTION;
}

static const struct command_registration telnet_subcommand_handlers[] = {
{
.name = "port",
.handler = handle_telnet_port_command,
.mode = COMMAND_CONFIG,
.help = "Specify port on which to listen "
"for incoming telnet connections. "
"Read help on 'gdb port'.",
.usage = "[port_num]",
},
COMMAND_REGISTRATION_DONE
};

static const struct command_registration telnet_command_handlers[] = {
{
.name = "exit",
Expand All @@ -987,13 +999,11 @@ static const struct command_registration telnet_command_handlers[] = {
.help = "exit telnet session",
},
{
.name = "telnet_port",
.handler = handle_telnet_port_command,
.name = "telnet",
.chain = telnet_subcommand_handlers,
.mode = COMMAND_CONFIG,
.help = "Specify port on which to listen "
"for incoming telnet connections. "
"Read help on 'gdb port'.",
.usage = "[port_num]",
.help = "telnet commands",
.usage = "",
},
COMMAND_REGISTRATION_DONE
};
Expand Down

0 comments on commit ad21613

Please sign in to comment.