13 #include <libtu/misc.h> |
13 #include <libtu/misc.h> |
14 #include <libtu/optparser.h> |
14 #include <libtu/optparser.h> |
15 |
15 |
16 |
16 |
17 static const char usage[]= |
17 static const char usage[]= |
18 "Usage: $p [options]\n" |
18 "Usage: $p [options]\n" |
19 "\n" |
19 "\n" |
20 "Where options are:\n" |
20 "Where options are:\n" |
21 "$o\n"; |
21 "$o\n"; |
22 |
22 |
23 |
23 |
24 static OptParserOpt opts[]={ |
24 static OptParserOpt opts[]={ |
25 {'o', "opt", OPT_ARG, "OPTION", "foo bar baz quk asdf jklö äölk dfgh quik aaaa bbbb cccc dddd eeee ffff"}, |
25 {'o', "opt", OPT_ARG, "OPTION", "foo bar baz quk asdf jklö äölk dfgh quik aaaa bbbb cccc dddd eeee ffff"}, |
26 {'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"}, |
26 {'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"}, |
27 {'v', "view", 0, NULL, "asfasdf"}, |
27 {'v', "view", 0, NULL, "asfasdf"}, |
28 {'z', "zip", 0, NULL, "asdfasdf"}, |
28 {'z', "zip", 0, NULL, "asdfasdf"}, |
29 {'x', "extract", 0, NULL, "asdfasdf"}, |
29 {'x', "extract", 0, NULL, "asdfasdf"}, |
30 {0, NULL, 0, NULL, NULL} |
30 {0, NULL, 0, NULL, NULL} |
31 }; |
31 }; |
32 |
32 |
33 static OptParserCommonInfo tester3_cinfo={ |
33 static OptParserCommonInfo tester3_cinfo={ |
34 NULL, |
34 NULL, |
35 usage, |
35 usage, |
36 NULL |
36 NULL |
37 }; |
37 }; |
38 |
38 |
39 |
39 |
40 int main(int argc, char *argv[]) |
40 int main(int argc, char *argv[]) |
41 { |
41 { |
42 int opt; |
42 int opt; |
43 |
43 |
44 libtu_init(argv[0]); |
44 libtu_init(argv[0]); |
45 |
45 |
46 optparser_init(argc, argv, OPTP_NO_DASH, opts, &tester3_cinfo); |
46 optparser_init(argc, argv, OPTP_NO_DASH, opts, &tester3_cinfo); |
47 |
47 |
48 while((opt=optparser_get_opt())){ |
48 while((opt=optparser_get_opt())){ |
49 switch(opt){ |
49 switch(opt){ |
50 case 'o': |
50 case 'o': |
51 printf("opt: %s\n", optparser_get_arg()); |
51 printf("opt: %s\n", optparser_get_arg()); |
52 break; |
52 break; |
53 case 'f': |
53 case 'f': |
54 printf("file: %s\n", optparser_get_arg()); |
54 printf("file: %s\n", optparser_get_arg()); |
55 break; |
55 break; |
56 case 'v': |
56 case 'v': |
57 printf("view\n"); |
57 printf("view\n"); |
58 break; |
58 break; |
59 case 'z': |
59 case 'z': |
60 printf("zip\n"); |
60 printf("zip\n"); |
61 break; |
61 break; |
62 case 'x': |
62 case 'x': |
63 printf("extract\n"); |
63 printf("extract\n"); |
64 break; |
64 break; |
65 default: |
65 default: |
66 optparser_print_error(); |
66 optparser_print_error(); |
67 return 1; |
67 return 1; |
68 } |
68 } |
69 } |
69 } |
70 return 0; |
70 return 0; |
71 } |
71 } |
72 |
72 |