Tag
Hash :
5a83cc2d
Author :
Date :
2011-07-06T16:47:29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#include <stdio.h>
#include <string.h>
#include "config.h"
/**
* opt - simple command line parsing
*
* Simple but powerful command line parsing.
*
* Example:
* #include <ccan/opt/opt.h>
* #include <stdio.h>
* #include <stdlib.h>
*
* static bool someflag;
* static int verbose;
* static char *somestring;
*
* static struct opt_table opts[] = {
* OPT_WITHOUT_ARG("--verbose|-v", opt_inc_intval, &verbose,
* "Verbose mode (can be specified more than once)"),
* OPT_WITHOUT_ARG("--someflag", opt_set_bool, &someflag,
* "Set someflag"),
* OPT_WITH_ARG("--somefile=<filename>", opt_set_charp, opt_show_charp,
* &somestring, "Set somefile to <filename>"),
* OPT_WITHOUT_ARG("--usage|--help|-h", opt_usage_and_exit,
* "args...\nA silly test program.",
* "Print this message."),
* OPT_ENDTABLE
* };
*
* int main(int argc, char *argv[])
* {
* int i;
*
* opt_register_table(opts, NULL);
* // For fun, register an extra one.
* opt_register_noarg("--no-someflag", opt_set_invbool, &someflag,
* "Unset someflag");
* if (!opt_parse(&argc, argv, opt_log_stderr))
* exit(1);
*
* printf("someflag = %i, verbose = %i, somestring = %s\n",
* someflag, verbose, somestring);
* printf("%u args left over:", argc - 1);
* for (i = 1; i < argc; i++)
* printf(" %s", argv[i]);
* printf("\n");
* return 0;
* }
*
* License: GPL (2 or any later version)
* Author: Rusty Russell <rusty@rustcorp.com.au>
*/
int main(int argc, char *argv[])
{
if (argc != 2)
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("ccan/typesafe_cb\n");
printf("ccan/compiler\n");
return 0;
}
return 1;
}