1
0
mirror of https://github.com/djcb/mu.git synced 2024-06-20 06:46:50 +02:00

* mu-config: better argument check, print usage info when no command is provided

This commit is contained in:
Dirk-Jan C. Binnema 2011-01-13 21:41:07 +02:00
parent 4aa838f6f6
commit a9a2e1f94f

View File

@ -249,7 +249,7 @@ parse_cmd (MuConfig *opts, int *argcp, char ***argvp)
opts->cmdstr = NULL; opts->cmdstr = NULL;
if (*argcp < 2) /* no command found at all */ if (*argcp < 2) /* no command found at all */
return FALSE; return TRUE;
else if ((**argvp)[1] == '-') else if ((**argvp)[1] == '-')
/* if the first param starts with '-', there is no /* if the first param starts with '-', there is no
* command, just some option (like --version, --help * command, just some option (like --version, --help
@ -258,6 +258,7 @@ parse_cmd (MuConfig *opts, int *argcp, char ***argvp)
opts->cmd = MU_CONFIG_CMD_UNKNOWN; opts->cmd = MU_CONFIG_CMD_UNKNOWN;
opts->cmdstr = (*argvp)[1]; opts->cmdstr = (*argvp)[1];
for (i = 0; i != G_N_ELEMENTS(cmd_map); ++i) for (i = 0; i != G_N_ELEMENTS(cmd_map); ++i)
if (strcmp (opts->cmdstr, cmd_map[i]._name) == 0) if (strcmp (opts->cmdstr, cmd_map[i]._name) == 0)
opts->cmd = cmd_map[i]._cmd; opts->cmd = cmd_map[i]._cmd;