-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdechrom.cpp
More file actions
85 lines (71 loc) · 1.97 KB
/
dechrom.cpp
File metadata and controls
85 lines (71 loc) · 1.97 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <argp.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "subcommands.h"
const char *argp_program_version = VERSION " " __DATE__;
//-------------------------------------------------------------------
// Command-line option parsing.
// Example at https://gist.github.com/sam-github/57f49711cd9073b35d22
//
// ## Top-level parser
static char doc_toplevel[1000];
static error_t parse_toplevel (int key, char *arg, struct argp_state *state) {
switch (key) {
case ARGP_KEY_ARG:
assert( arg );
if(strcmp(arg, "survey") == 0) {
run_survey(state);
}
else if(strcmp(arg, "find") == 0) {
run_find(state);
}
else if(strcmp(arg, "plot") == 0) {
run_plot(state);
}
else if(strcmp(arg, "radial") == 0) {
run_radial(state);
}
else if(strcmp(arg, "view") == 0) {
run_view(state);
}
else {
argp_error(state, "%s is not a valid command", arg);
}
break;
case ARGP_KEY_END:
if (state->arg_num < 2)
argp_usage (state);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
static struct argp argp_toplevel = {
0, // no options
parse_toplevel,
"<COMMAND> <ARGS>",
doc_toplevel
};
#pragma GCC diagnostic pop
int main(int argc, char **argv) {
sprintf(
doc_toplevel,
"\n"
"Utilities for correcting transverse chromatic aberration\n"
"Version: %s\n"
"\n"
"Command: survey sample TCA in a volume of parameter space\n"
" plot generate an R program to display survey data\n"
" find find optimal distortion parameters\n"
" radial apply a radial distortion to an image\n"
" view examine channel convergence\n"
"\n",
argp_program_version
);
argp_parse (&argp_toplevel, argc, argv, ARGP_IN_ORDER, NULL, NULL);
return(EXIT_SUCCESS);
}