| 11237 | } |
| 11238 | |
| 11239 | int cbm_cmd_install(int argc, char **argv) { |
| 11240 | parse_auto_answer(argc, argv); |
| 11241 | bool dry_run = false; |
| 11242 | bool force = false; |
| 11243 | bool plan = false; |
| 11244 | bool reset_indexes = false; |
| 11245 | bool skip_config = false; |
| 11246 | bool skip_binary = false; |
| 11247 | bool force_binary = false; |
| 11248 | const char *requested_clients = NULL; |
| 11249 | const char *requested_bin_dir = NULL; |
| 11250 | for (int i = 0; i < argc; i++) { |
| 11251 | if (strcmp(argv[i], "--dry-run") == 0) { |
| 11252 | dry_run = true; |
| 11253 | } else if (strcmp(argv[i], "--force") == 0) { |
| 11254 | force = true; |
| 11255 | } else if (strcmp(argv[i], "--plan") == 0) { |
| 11256 | plan = true; |
| 11257 | } else if (strcmp(argv[i], "--reset-indexes") == 0) { |
| 11258 | reset_indexes = true; |
| 11259 | } else if (strcmp(argv[i], "--skip-config") == 0) { |
| 11260 | skip_config = true; |
| 11261 | } else if (strncmp(argv[i], "--clients=", SLEN("--clients=")) == 0) { |
| 11262 | requested_clients = argv[i] + SLEN("--clients="); |
| 11263 | if (!requested_clients[0]) { |
| 11264 | (void)fprintf(stderr, "error: --clients requires a value\n\n"); |
| 11265 | cli_clients_print_list(stderr); |
| 11266 | return CLI_TRUE; |
| 11267 | } |
| 11268 | } else if (strcmp(argv[i], "--clients") == 0) { |
| 11269 | /* Bare `--clients` (and `--clients=help`/`list`) print the |
| 11270 | * vocabulary, including tokens users would not readily guess. */ |
| 11271 | cli_clients_print_list(stdout); |
| 11272 | return 0; |
| 11273 | } else if (strcmp(argv[i], "--skip-binary") == 0) { |
| 11274 | /* #1566: the mirror of --skip-config. Configure the agents, leave |
| 11275 | * the binary and PATH alone. */ |
| 11276 | skip_binary = true; |
| 11277 | } else if (strcmp(argv[i], "--force-binary") == 0) { |
| 11278 | force_binary = true; |
| 11279 | } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) { |
| 11280 | requested_bin_dir = argv[i] + SLEN("--dir="); |
| 11281 | if (!requested_bin_dir[0]) { |
| 11282 | (void)fprintf(stderr, "error: --dir requires a non-empty path\n"); |
| 11283 | return CLI_TRUE; |
| 11284 | } |
| 11285 | } else if (strcmp(argv[i], "--dir") == 0) { |
| 11286 | if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') { |
| 11287 | (void)fprintf(stderr, "error: --dir requires a non-empty path\n"); |
| 11288 | return CLI_TRUE; |
| 11289 | } |
| 11290 | requested_bin_dir = argv[++i]; |
| 11291 | } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 && |
| 11292 | strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) { |
| 11293 | (void)fprintf(stderr, "error: unknown install option: %s\n", argv[i]); |
| 11294 | return CLI_TRUE; |
| 11295 | } |
| 11296 | } |
no test coverage detected