-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
51 lines (38 loc) · 991 Bytes
/
Copy pathexample.c
File metadata and controls
51 lines (38 loc) · 991 Bytes
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
#include <stdio.h>
#include "arglib.h"
int main(int argc, char *argv[]){
// For each arg
arg_args (argc, argv) {
arg_option ('h', "Show this menu")
// Pass in the current function as the argument function
arg_help(main);
// Takes a value
arg_option ('t', "Test arg (takes a value)") {
// Print value if its given:
if arg_hasvalue {
// Get the value after the '='
char *value = arg_align;
printf("-t was run with value: %s\n", value);
} else puts("-t was run with no value");
}
// Takes a value
arg_option ('T', "Test arg (takes a value)") {
// Print value if its given:
if arg_hasvalue {
// Get the value after the '='
char *value = arg_align;
printf("-t was run with value: %s\n", value);
} else puts("-t was run with no value");
}
arg_notfound {
printf("Unrecognised: %c\n", arg_value);
return 1;
}
}
// If no args were given
if (argc == 1){
puts("use -h for info");
return 1;
}
return 0;
}