tester3.c

changeset 12
5fd153b29d40
parent 9
55e7f2ff6021
child 17
a034888a2227
equal deleted inserted replaced
11:3ea4e7930c5b 12:5fd153b29d40
11 #include <libtu/misc.h> 11 #include <libtu/misc.h>
12 #include <libtu/optparser.h> 12 #include <libtu/optparser.h>
13 13
14 14
15 static const char usage[]= 15 static const char usage[]=
16 "$u [options]\n" 16 "Usage: $p [options]\n"
17 "\n" 17 "\n"
18 "Where options are:\n" 18 "Where options are:\n"
19 "\n" 19 "$o\n";
20 " -o, -f, -v, -z, -x\n"
21 "$c \n"
22 "\n";
23 20
24 21
25 static ProgInfo proginfo={
26 "Tester III",
27 "0.1",
28 "foo",
29 "bar",
30 usage
31 };
32
33
34 static OptParserOpt opts[]={ 22 static OptParserOpt opts[]={
35 {'o', "opt", OPT_ARG}, 23 {'o', "opt", OPT_ARG, "OPTION", "foo bar baz quk asdf jklö äölk dfgh quik aaaa bbbb cccc dddd eeee ffff"},
36 {'f', "file", OPT_ARG}, 24 {'f', "file", OPT_ARG, "FILE", "asdfsadlfölökjasdflökjasdflkjöasdflkjöas dlöfjkasdfölkjasdfölkjasdfasdflöjasdfkasödjlfkasdlföjasdölfjkölkasjdfasdfölkjasd asdöljfasöldf asdölfköasdlf asfdlök asdföljkadsfölasdfölasdölkfjasdölfasödlflöskflasdföaölsdf"},
37 {'v', "view", 0}, 25 {'v', "view", 0, NULL, NULL},
38 {'z', "zip", 0}, 26 {'z', "zip", 0, NULL, NULL},
39 {'x', "extract", 0}, 27 {'x', "extract", 0, NULL, NULL},
40 {0, NULL, 0} 28 {0, NULL, 0, NULL, NULL}
41 }; 29 };
42 30
43 31
44 int main(int argc, char *argv[]) 32 int main(int argc, char *argv[])
45 { 33 {
46 int opt; 34 int opt;
47 35
48 libtu_init(&argc, argv, &proginfo); 36 libtu_init(argv[0]);
49 37
50 optparser_init(argc, argv, OPTP_NO_DASH, opts); 38 optparser_init(argc, argv, OPTP_NO_DASH, opts, NULL);
51 39
52 while((opt=optparser_get_opt())){ 40 while((opt=optparser_get_opt())){
53 switch(opt){ 41 switch(opt){
54 case 'o': 42 case 'o':
55 printf("opt: %s\n", optparser_get_arg()); 43 printf("opt: %s\n", optparser_get_arg());

mercurial