-static struct opt_section help = {
- OPT_ITEMS {
- OPT_HELP("A simple tea boiling console."),
- OPT_HELP("Usage: teapot [options] name-of-the-tea"),
- OPT_HELP("Black, green or white tea supported as well as fruit or herbal tea."),
- OPT_HELP("You may specify more kinds of tea, all of them will be boiled for you, in the given order."),
- OPT_HELP(""),
- OPT_HELP("Options:"),
- OPT_HELP_OPTION,
- OPT_CALL('V', "version", show_version, NULL, OPT_NO_VALUE, "\tShow the version"),
- OPT_HELP(""),
- OPT_BOOL('e', "english-style", english, 0, "\tEnglish style (with milk)"),
- OPT_INT('s', "sugar", sugar, OPT_REQUIRED_VALUE, "<spoons>\tAmount of sugar (in teaspoons)"),
- OPT_SWITCH(0, "standard-set", set, TEAPOT_STANDARD, 0, "\tStandard teapot"),
- OPT_SWITCH('x', "exclusive-set", set, TEAPOT_EXCLUSIVE, 0, "\tExclusive teapot"),
- OPT_SWITCH('g', "glass-set", set, TEAPOT_GLASS, 0, "\tTransparent glass teapot"),
- OPT_SWITCH('h', "hands", set, TEAPOT_HANDS, 0, "\tUse user's hands as a teapot (a bit dangerous)"),
- OPT_USER('t', "temperature", temperature, teapot_temperature_t, OPT_REQUIRED_VALUE | OPT_REQUIRED,
- "<value>\tWanted final temperature of the tea to be served\n"
- "\t\tSupported scales: Celsius [60C], Fahrenheit [140F],\n"
- "\t\t Kelvin [350K], Rankine [600R] and Reaumur [50Re]\n"
- "\t\tOnly integer values allowed."),
- OPT_INC('v', "verbose", verbose, 0, "\tVerbose (the more -v, the more verbose)"),
- OPT_INC('q', "quiet", verbose, OPT_NEGATIVE, "\tQuiet (the more -q, the more quiet)"),
- OPT_INT('b', "black-magic", black_magic, 0, "<strength>\tUse black magic to make the tea extraordinary delicious"),
- OPT_BOOL('p', "pray", pray, OPT_SINGLE, "\tPray before boiling"),
- OPT_HELP(""),
- OPT_HELP("Water options:"),
- OPT_SECTION(water_options),
- OPT_END
- }
-};
-
-#define MAX_TEA_COUNT 30
-static char * tea_list[MAX_TEA_COUNT];
-static int tea_num = 0;
-static void add_tea(const char * name) {
- if (tea_num >= MAX_TEA_COUNT) {
- fprintf(stderr, "Cannot boil more than %d teas.\n", MAX_TEA_COUNT);
- exit(OPT_EXIT_BAD_ARGS);
+ int force_positional = 0;
+ int i;
+ for (i=0; argv[i] && !oc->stop_parsing; i++) {
+ char *arg = argv[i];
+ opt_invoke_hooks(oc, OPT_HOOK_BEFORE_ARG, NULL, NULL);
+ if (arg[0] != '-' || force_positional)
+ opt_positional(oc, arg);
+ else {
+ if (arg[1] == '-') {
+ if (arg[2] == '\0')
+ force_positional++;
+ else
+ i += opt_longopt(oc, argv, i);
+ } else if (arg[1])
+ i += opt_shortopt(oc, argv, i);
+ else
+ opt_positional(oc, arg);
+ }