diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-01-08 18:15:55 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-01-13 15:09:09 +0100 |
commit | 133fc03a8aac694d2d96d8e1de30467930a67bc9 (patch) | |
tree | 7130562647910d4e30e519b174d3446bcccf25fc /common/complete.c | |
parent | ec945f352178470d39aa0f7c407fc4ae859b34b0 (diff) | |
download | barebox-133fc03a8aac694d2d96d8e1de30467930a67bc9.tar.gz |
commands: add new tutorial command
We have a web demo at http://barebox.org/jsbarebox and it would
be nice to have a tutorial there. Add a new tutorial command that
cycles through a number of tips.
Tutorial will follow later.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220108171555.588426-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/complete.c')
-rw-r--r-- | common/complete.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/common/complete.c b/common/complete.c index e504b75606..ab3c985493 100644 --- a/common/complete.c +++ b/common/complete.c @@ -14,17 +14,18 @@ #include <command.h> #include <environment.h> -static int file_complete(struct string_list *sl, char *instr, int exec) +static int file_complete(struct string_list *sl, char *instr, + const char *dirn, int exec) { char *path = strdup(instr); struct stat s; DIR *dir; struct dirent *d; char tmp[PATH_MAX]; - char *base, *dirn; + char *base; base = basename(instr); - dirn = dirname(path); + dirn = dirn ?: dirname(path); dir = opendir(dirn); if (!dir) @@ -250,12 +251,20 @@ EXPORT_SYMBOL(devicetree_complete); int devicetree_file_complete(struct string_list *sl, char *instr) { devicetree_complete(sl, instr); - file_complete(sl, instr, 0); + file_complete(sl, instr, NULL, 0); return 0; } EXPORT_SYMBOL(devicetree_file_complete); +int tutorial_complete(struct string_list *sl, char *instr) +{ + file_complete(sl, instr, "/env/data/tutorial", 0); + + return 0; +} +EXPORT_SYMBOL(tutorial_complete); + static int env_param_complete(struct string_list *sl, char *instr, int eval) { struct device_d *dev; @@ -392,11 +401,11 @@ int complete(char *instr, char **outstr) if (!instr) { instr = t; if (t && (t[0] == '/' || !strncmp(t, "./", 2))) { - file_complete(&sl, t, 1); + file_complete(&sl, t, NULL, 1); instr = t; } else if ((t = strrchr(t, ' '))) { t++; - file_complete(&sl, t, 0); + file_complete(&sl, t, NULL, 0); instr = t; } else { command_complete(&sl, instr); |