| 279 | } |
| 280 | |
| 281 | int main(int argc, char *argv[]) { |
| 282 | bool ret = true; |
| 283 | |
| 284 | s3ext_loglevel = EXT_ERROR; |
| 285 | s3ext_logtype = STDERR_LOG; |
| 286 | |
| 287 | if (argc == 1) { |
| 288 | printUsage(stderr); |
| 289 | exit(EXIT_FAILURE); |
| 290 | } |
| 291 | |
| 292 | /* Prepare to receive interrupts */ |
| 293 | registerSignalHandler(); |
| 294 | |
| 295 | map<char, string> optionPairs = parseCommandLineArgs(argc, argv); |
| 296 | |
| 297 | validateCommandLineArgs(optionPairs); |
| 298 | |
| 299 | if (!optionPairs.empty()) { |
| 300 | const char *arg = optionPairs.begin()->second.c_str(); |
| 301 | |
| 302 | switch (optionPairs.begin()->first) { |
| 303 | case 'c': |
| 304 | ret = checkConfig(arg); |
| 305 | break; |
| 306 | case 'd': |
| 307 | ret = downloadS3(arg); |
| 308 | break; |
| 309 | case 'u': |
| 310 | case 'f': |
| 311 | ret = uploadS3(optionPairs['u'].c_str(), optionPairs['f'].c_str()); |
| 312 | break; |
| 313 | case 'h': |
| 314 | printUsage(stdout); |
| 315 | break; |
| 316 | case 't': |
| 317 | printTemplate(); |
| 318 | break; |
| 319 | default: |
| 320 | printUsage(stderr); |
| 321 | exit(EXIT_FAILURE); |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | // Abort should not print the failed info |
| 326 | if (ret || S3QueryIsAbortInProgress()) { |
| 327 | exit(EXIT_SUCCESS); |
| 328 | } else { |
| 329 | fprintf(stderr, "Failed. Please check the arguments and configuration file.\n\n"); |
| 330 | printUsage(stderr); |
| 331 | exit(EXIT_FAILURE); |
| 332 | } |
| 333 | } |
nothing calls this directly
no test coverage detected