73 if(argc == 1 || ((strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-h") == 0) && argc == 2)) {
76 }
else if(argc >= 3 && (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-h") == 0)) {
77 if(strcmp(argv[2],
"--help") == 0 || strcmp(argv[2],
"-h") == 0 || strcmp(argv[2],
"help") == 0 || strcmp(argv[2],
"h") == 0)
79 else if(strcmp(argv[2],
"--go") == 0 || strcmp(argv[2],
"-g") == 0 || strcmp(argv[2],
"go") == 0 || strcmp(argv[2],
"g") == 0)
81 else if(strcmp(argv[2],
"--dont-ask-config-options") == 0 || strcmp(argv[2],
"-d") == 0 || strcmp(argv[2],
"dont-ask-config-options") == 0 || strcmp(argv[2],
"d") == 0)
82 getHelp(
"dont-ask-config-options");
83 else if(strcmp(argv[2],
"--ignore-config-file") == 0 || strcmp(argv[2],
"-c") == 0 || strcmp(argv[2],
"ignore-config-file") == 0 || strcmp(argv[2],
"c") == 0)
85 else if(strcmp(argv[2],
"--save-to-file") == 0 || strcmp(argv[2],
"-S") == 0 || strcmp(argv[2],
"save-to-file") == 0 || strcmp(argv[2],
"S") == 0)
87 else if(strcmp(argv[2],
"--use-tui") == 0 || strcmp(argv[2],
"-t") == 0 || strcmp(argv[2],
"use-tui") == 0 || strcmp(argv[2],
"t") == 0)
89 else if(strcmp(argv[2],
"--verbose") == 0 || strcmp(argv[2],
"-v") == 0 || strcmp(argv[2],
"verbose") == 0 || strcmp(argv[2],
"v") == 0)
91 else if(strcmp(argv[2],
"--default-player-LPs") == 0 || strcmp(argv[2],
"-p") == 0 || strcmp(argv[2],
"default-player-LPs") == 0 || strcmp(argv[2],
"p") == 0)
93 else if(strcmp(argv[2],
"--default-LPs-field") == 0 || strcmp(argv[2],
"-f") == 0 || strcmp(argv[2],
"default-LPs-field") == 0 || strcmp(argv[2],
"f") == 0)
95 else if(strcmp(argv[2],
"--allow-same-rank") == 0 || strcmp(argv[2],
"-r") == 0 || strcmp(argv[2],
"allow-same-rank") == 0 || strcmp(argv[2],
"r") == 0)
97 else if(strcmp(argv[2],
"--allow-same-suit") == 0 || strcmp(argv[2],
"-s") == 0 || strcmp(argv[2],
"allow-same-suit") == 0 || strcmp(argv[2],
"s") == 0)
100 printf(
"Illegal CLI arguments: help option was not recognized.\n");
108 for(
int i = 1; i < argc; i++) {
109 if(strcmp(argv[i],
"--go") == 0 || strcmp(argv[i],
"-g") == 0)
111 else if(strcmp(argv[i],
"--dont-ask-config-options") == 0 || strcmp(argv[i],
"-d") == 0)
113 else if(strcmp(argv[i],
"--ignore-config-file") == 0 || strcmp(argv[i],
"-c") == 0)
115 else if(strcmp(argv[i],
"--save-to-file") == 0 || strcmp(argv[i],
"-S") == 0)
117 else if(strcmp(argv[i],
"--use-tui") == 0 || strcmp(argv[i],
"-t") == 0)
119 else if(strcmp(argv[i],
"--verbose") == 0 || strcmp(argv[i],
"-v") == 0)
124 printf(
"Illegal CLI argument: not recognized argument%c.\n", argc > 2 ?
's' : 0);
127 printf(
"Illegal CLI arguments: --go option must be passed with options --dont-ask-config-options and --ignore-config-file.\n");
138 for(
int i = 1; i < argc; i++) {
149 char* optionName =
"";
150 char* optionValue =
"";
154 optionName =
substring(argv[i], 0, equalPosition);
155 optionValue =
substring(argv[i], equalPosition + 1, strlen(argv[i]) - equalPosition - 1);
157 optionName = argv[i];
158 optionValue = argv[i + 1];
165 if(strcmp(optionName,
"--default-player-LPs") == 0 || strcmp(optionName,
"-p") == 0) {
166 int n = strtol(optionValue, &endptr, 10);
168 if(errno == ERANGE || *endptr !=
'\0') {
169 printf(
"Illegal CLI arguments: a number was expected.\n");
174 }
else if(strcmp(optionName,
"--default-LPs-field") == 0 || strcmp(optionName,
"-f") == 0) {
175 int n = strtol(optionValue, &endptr, 10);
177 if(errno == ERANGE || *endptr !=
'\0') {
178 printf(
"Illegal CLI arguments: a number was expected.\n");
183 }
else if(strcmp(optionName,
"--allow-same-rank") == 0 || strcmp(optionName,
"-r") == 0) {
184 if(strcmp(optionValue,
"true") == 0 || strcmp(optionValue,
"false") == 0)
187 printf(
"Illegal CLI arguments: true or false were expected.\n");
190 }
else if(strcmp(optionName,
"--allow-same-suit") == 0 || strcmp(optionName,
"-s") == 0) {
191 if(strcmp(optionValue,
"true") == 0 || strcmp(optionValue,
"false") == 0)
194 printf(
"Illegal CLI arguments: true or false were expected.\n");