1
2
3#include "toys.h"
4
5#include "generated/help.h"
6
7#undef NEWTOY
8#undef OLDTOY
9#define NEWTOY(name,opt,flags) HELP_##name "\0"
10#if CFG_TOYBOX
11#define OLDTOY(name,oldname,flags) "\xff" #oldname "\0"
12#else
13#define OLDTOY(name, oldname, flags) HELP_##oldname "\0"
14#endif
15static char *help_data =
16#include "generated/newtoys.h"
17;
18
19void show_help(FILE *out, int full)
20{
21 int i = toys.which-toy_list;
22 char *s, *ss;
23
24 if (!(full&2))
25 fprintf(out, "Toybox %s" USE_TOYBOX(" multicall binary")
26 ": https://landley.net/toybox"
27 USE_TOYBOX(" (see toybox --help)") "\n\n", toybox_version);
28
29 if (CFG_TOYBOX_HELP) {
30 for (;;) {
31 s = help_data;
32 while (i--) s += strlen(s) + 1;
33
34 if (*s != 255) break;
35 i = toy_find(++s)-toy_list;
36 }
37
38 if (full) fprintf(out, "%s\n", s);
39 else {
40 strstart(&s, "usage: ");
41 for (ss = s; *ss && *ss!='\n'; ss++);
42 fprintf(out, "%.*s\n", (int)(ss-s), s);
43 }
44 }
45}
46