summaryrefslogtreecommitdiff
path: root/common/console.c
diff options
context:
space:
mode:
authorGerrit <chrome-bot@google.com>2012-05-14 14:40:44 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2012-05-14 14:40:44 -0700
commitd296c0d2462f799d26d579d8c2e0d0eab35c4a5f (patch)
tree36b22cdb978009240cf444469da170af19bf5f3c /common/console.c
parente9f4bf29c1ece072be59c25ce6127346c4ca48ba (diff)
parent6a324c1de569529b26ebc694ceca3a66c38c989d (diff)
downloadchrome-ec-d296c0d2462f799d26d579d8c2e0d0eab35c4a5f.tar.gz
Merge "Allow console commands abbreviation"
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/common/console.c b/common/console.c
index 50ca6da2d4..cdb5daf5e6 100644
--- a/common/console.c
+++ b/common/console.c
@@ -128,14 +128,18 @@ static int split_words(char *input, int max_argc, int *argc, char **argv)
* no match found. */
static const struct console_command *find_command(char *name)
{
- const struct console_command *cmd;
+ const struct console_command *cmd, *match = NULL;
+ int match_length = strlen(name);
for (cmd = __cmds; cmd < __cmds_end; cmd++) {
- if (!strcasecmp(name, cmd->name))
- return cmd;
+ if (!strncasecmp(name, cmd->name, match_length)) {
+ if (match)
+ return NULL;
+ match = cmd;
+ }
}
- return NULL;
+ return match;
}
@@ -159,7 +163,7 @@ static int handle_command(char *input)
if (cmd)
return cmd->handler(argc, argv);
- ccprintf("Command '%s' not found.\n", argv[0]);
+ ccprintf("Command '%s' either not found or ambiguous.\n", argv[0]);
return EC_ERROR_UNKNOWN;
}
@@ -293,7 +297,7 @@ static int command_ch(int argc, char **argv)
}
/* Otherwise, print help */
- ccputs("Usage: ch [newmask]\n");
+ ccputs("Usage: chan [newmask]\n");
return EC_ERROR_INVAL;
};
-DECLARE_CONSOLE_COMMAND(ch, command_ch);
+DECLARE_CONSOLE_COMMAND(chan, command_ch);