diff options
Diffstat (limited to 'src/food.c')
-rw-r--r-- | src/food.c | 55 |
1 files changed, 23 insertions, 32 deletions
@@ -1,8 +1,9 @@ -#include <getopt.h> +//#include <getopt.h> #include "util.h" #include "parser.h" #include "search.h" +#include "foodopts.h" #include "eval.h" #include "lib.h" @@ -66,33 +67,28 @@ main(int argc, char * argv[]) int c; + struct foodoption long_options[] = + {/* name, has_arg, flag, val, help, arg */ + {"help", no_argument, 0, 'h', "Print this help", 0}, + {"no-eval", no_argument, 0, 'n', "Don't evaluate recipes", 0}, + {"to-json", no_argument, 0, 'j', "Format recipe to json", 0}, + {"to-html", no_argument, 0, 'w', "Format recipe to html", 0}, + {"to-rcp", no_argument, 0, 'r', "Format recipe to rcp", 0}, + {"add-item", required_argument, 0, 'a', "Add item to matched recipes", "ITEM"}, + //{"add-step", required_argument, 0, 'o'},, 0 + {"format", required_argument, 0, 'f', "Select recipe formatting", "{json,html,rcp}"}, + {"include", required_argument, 0, 'I', "Path to recipe library, can be passed many times", "PATH"}, + {"search", required_argument, 0, 's', "Return recipes matching QUERY", "QUERY"}, + {"title", required_argument, 0, 't', "Return recipes matching TITLE", "TITLE"}, + {"strict", required_argument, 0, 'S', "Return recipes matching QUERY, exaclty", "QUERY"}, + {"hash", required_argument, 0, 'H', "Return recipes by HASH", "HASH"}, + {"list-ingredients", no_argument, 0, 'l', "List ingredients for matched recipes", 0}, + {0, 0, 0, 0, 0} + }; while (1) { - static struct option long_options[] = - { - /* <span class="roman">These options set a flag.</span> */ - // {"verbose", no_argument, &verbose_flag, 1}, - // {"brief", no_argument, &verbose_flag, 0}, - {"help", no_argument, 0, 'h'}, - {"no-eval", no_argument, 0, 'n'}, - {"to-json", no_argument, 0, 'j'}, - {"to-html", no_argument, 0, 'w'}, - {"to-rcp", no_argument, 0, 'r'}, - {"add-item", required_argument, 0, 'a'}, - //{"add-step", required_argument, 0, 'o'}, - {"format", required_argument, 0, 'f'}, - {"include", required_argument, 0, 'I'}, - {"search", required_argument, 0, 's'}, - {"title", required_argument, 0, 't'}, - {"strict", required_argument, 0, 'S'}, - {"hash", required_argument, 0, 'H'}, - {"list-ingredients", no_argument, 0, 'l'}, - // {"to-rcp", required_argument, 0, 'r'}, - {0, 0, 0, 0} - }; - int option_index = 0; - c = getopt_long (argc, argv, "jnlhrwf:s:S:t:H:I:a:", + c = get_foodopt (argc, argv, "jnlhrwf:s:S:t:H:I:a:", long_options, &option_index); if (c == -1) @@ -100,12 +96,7 @@ main(int argc, char * argv[]) switch (c) { case 0: - if (long_options[option_index].flag != 0) - break; - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); + printf("Flag setting\n"); break; case 'f': if (!strcmp(optarg, "json")) @@ -168,7 +159,7 @@ main(int argc, char * argv[]) } if (opt.help) { - print_help(argv[0]); + foodopt_help(argv[0], long_options); return 0; } |