Looks cleaner than a big switch statement.
Signed-off-by: NeilBrown <neilb@suse.de>
"\n"
;
+char *mode_help[mode_count] = {
+ [0] = Help,
+ [ASSEMBLE] = Help_assemble,
+ [BUILD] = Help_build,
+ [CREATE] = Help_create,
+ [MANAGE] = Help_manage,
+ [MISC] = Help_misc,
+ [MONITOR] = Help_monitor,
+ [GROW] = Help_grow,
+ [INCREMENTAL] = Help_incr,
+};
}
if (print_help) {
- char *help_text = Help;
+ char *help_text;
if (print_help == 2)
help_text = OptionHelp;
else
- switch (mode) {
- case ASSEMBLE : help_text = Help_assemble; break;
- case BUILD : help_text = Help_build; break;
- case CREATE : help_text = Help_create; break;
- case MANAGE : help_text = Help_manage; break;
- case MISC : help_text = Help_misc; break;
- case MONITOR : help_text = Help_monitor; break;
- case GROW : help_text = Help_grow; break;
- case INCREMENTAL:help_text= Help_incr; break;
- }
+ help_text = mode_help[mode];
+ if (help_text == NULL)
+ help_text = Help;
fputs(help_text,stdout);
exit(0);
}
GROW,
INCREMENTAL,
AUTODETECT,
+ mode_count
};
extern char short_options[];
extern char short_bitmap_auto_options[];
extern struct option long_options[];
extern char Version[], Usage[], Help[], OptionHelp[],
+ *mode_help[],
Help_create[], Help_build[], Help_assemble[], Help_grow[],
Help_incr[],
Help_manage[], Help_misc[], Help_monitor[], Help_config[];