Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
openocd
Commits
910bb250
Commit
910bb250
authored
Nov 24, 2009
by
Zachary T Welch
Browse files
combine help and usage command handlers
Remove duplicated handler code by checking the running command name.
parent
c297a14f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/helper/command.c
View file @
910bb250
...
...
@@ -861,30 +861,18 @@ static COMMAND_HELPER(command_help_show, struct command *c, unsigned n,
}
COMMAND_HANDLER
(
handle_help_command
)
{
struct
command
*
c
=
CMD_CTX
->
commands
;
if
(
0
==
CMD_ARGC
)
return
CALL_COMMAND_HANDLER
(
command_help_show_list
,
c
,
0
,
true
);
bool
full
=
strcmp
(
CMD_NAME
,
"help"
)
==
0
;
int
retval
=
CALL_COMMAND_HANDLER
(
command_help_find
,
c
,
&
c
);
if
(
ERROR_OK
!=
retval
)
return
retval
;
return
CALL_COMMAND_HANDLER
(
command_help_show
,
c
,
0
,
true
);
}
COMMAND_HANDLER
(
handle_usage_command
)
{
struct
command
*
c
=
CMD_CTX
->
commands
;
if
(
0
==
CMD_ARGC
)
return
CALL_COMMAND_HANDLER
(
command_help_show_list
,
c
,
0
,
f
alse
);
return
CALL_COMMAND_HANDLER
(
command_help_show_list
,
c
,
0
,
f
ull
);
int
retval
=
CALL_COMMAND_HANDLER
(
command_help_find
,
c
,
&
c
);
if
(
ERROR_OK
!=
retval
)
return
retval
;
return
CALL_COMMAND_HANDLER
(
command_help_show
,
c
,
0
,
f
alse
);
return
CALL_COMMAND_HANDLER
(
command_help_show
,
c
,
0
,
f
ull
);
}
static
int
command_unknown_find
(
unsigned
argc
,
Jim_Obj
*
const
*
argv
,
...
...
@@ -1106,15 +1094,15 @@ static const struct command_registration command_builtin_handlers[] = {
.
name
=
"help"
,
.
handler
=
&
handle_help_command
,
.
mode
=
COMMAND_ANY
,
.
help
=
"show
built-in
command help"
,
.
usage
=
"[<command
_name
> ...]"
,
.
help
=
"show
full
command help"
,
.
usage
=
"[<command> ...]"
,
},
{
.
name
=
"usage"
,
.
handler
=
&
handle_
usage
_command
,
.
handler
=
&
handle_
help
_command
,
.
mode
=
COMMAND_ANY
,
.
help
=
"show command usage"
,
.
usage
=
"[<command
_name
> ...]"
,
.
help
=
"show
basic
command usage"
,
.
usage
=
"[<command> ...]"
,
},
COMMAND_REGISTRATION_DONE
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment