From 1fa17ad5d479714f46024c51a238b0f320b6e8d3 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Sun, 5 Jun 2011 20:58:08 +0800 Subject: complete: add device name complete support for devinfo Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- common/complete.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'common/complete.c') diff --git a/common/complete.c b/common/complete.c index d84839637c..c2b37e4e02 100644 --- a/common/complete.c +++ b/common/complete.c @@ -145,6 +145,26 @@ int command_complete(struct string_list *sl, char *instr) return 0; } +int device_complete(struct string_list *sl, char *instr) +{ + struct device_d *dev; + int len; + + if (!instr) + instr = ""; + + len = strlen(instr); + + for_each_device(dev) { + if (strncmp(instr, dev_name(dev), len)) + continue; + + string_list_add_asprintf(sl, "%s ", dev_name(dev)); + } + + return COMPLETE_CONTINUE; +} + static int device_param_complete(char *begin, struct device_d *dev, struct string_list *sl, char *instr) { -- cgit v1.2.3