Automatically show help for a command when it fails with a syntax error

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1703 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 15 years ago
parent 89eca7f45b
commit 12400cdcd6

@ -3,6 +3,9 @@
* src/cmd/cmd.h, src/cmd/cmd_list.h, src/cmd/cmd_cmd.c: Unify the list of
commands in one place.
* src/cmd/cmd_cmd.c (urj_cmd_run): Automatically show help for a command
when it fails with a syntax error.
2010-01-22 Mike Frysinger <vapier@gentoo.org>
* src/cmd/cmd_bit.c (cmd_bit_print_params): Fix strncat length handling.

@ -105,7 +105,13 @@ urj_cmd_run (urj_chain_t *chain, char *params[])
if (strcasecmp (urj_cmds[i]->name, params[0]) == 0)
{
run_cmd:
return urj_cmds[i]->run (chain, params);
i = urj_cmds[i]->run (chain, params);
if (i != URJ_STATUS_OK && urj_error_get () == URJ_ERROR_SYNTAX)
{
char *help_params[3] = { "help", params[0], NULL };
urj_cmd_run( chain, help_params );
}
return i;
}
else if (strncasecmp (urj_cmds[i]->name, params[0], len) == 0)
{

Loading…
Cancel
Save