• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Function to display help text
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
15 static char *help_data =
16 #include "generated/newtoys.h"
17 ;
18 
show_help(FILE * out)19 void show_help(FILE *out)
20 {
21   int i = toys.which-toy_list;
22   char *s;
23 
24   if (CFG_TOYBOX_HELP) {
25     for (;;) {
26       s = help_data;
27       while (i--) s += strlen(s) + 1;
28       // If it's an alias, restart search for real name
29       if (*s != 255) break;
30       i = toy_find(++s)-toy_list;
31     }
32 
33     fprintf(out, "%s\n", s);
34   }
35 }
36