summaryrefslogtreecommitdiffstats
path: root/common/complete.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2011-06-05 20:58:08 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-04-30 20:37:34 +0800
commit1fa17ad5d479714f46024c51a238b0f320b6e8d3 (patch)
treea6d92a82c68ed496ebd6232238e8fa30d810b4fa /common/complete.c
parent9dfb0030ee60306bfd1e6e86560685c44bede9e7 (diff)
downloadbarebox-1fa17ad5d479714f46024c51a238b0f320b6e8d3.tar.gz
complete: add device name complete support for devinfo
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'common/complete.c')
-rw-r--r--common/complete.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/complete.c b/common/complete.c
index d848396..c2b37e4 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)
{