| 11018 | } |
| 11019 | |
| 11020 | int cbm_cmd_install(int argc, char **argv) { |
| 11021 | parse_auto_answer(argc, argv); |
| 11022 | bool dry_run = false; |
| 11023 | bool force = false; |
| 11024 | bool plan = false; |
| 11025 | bool reset_indexes = false; |
| 11026 | bool skip_config = false; |
| 11027 | bool skip_binary = false; |
| 11028 | bool force_binary = false; |
| 11029 | const char *requested_clients = NULL; |
| 11030 | const char *requested_bin_dir = NULL; |
| 11031 | for (int i = 0; i < argc; i++) { |
| 11032 | if (strcmp(argv[i], "--dry-run") == 0) { |
| 11033 | dry_run = true; |
| 11034 | } else if (strcmp(argv[i], "--force") == 0) { |
| 11035 | force = true; |
| 11036 | } else if (strcmp(argv[i], "--plan") == 0) { |
| 11037 | plan = true; |
| 11038 | } else if (strcmp(argv[i], "--reset-indexes") == 0) { |
| 11039 | reset_indexes = true; |
| 11040 | } else if (strcmp(argv[i], "--skip-config") == 0) { |
| 11041 | skip_config = true; |
| 11042 | } else if (strncmp(argv[i], "--clients=", SLEN("--clients=")) == 0) { |
| 11043 | requested_clients = argv[i] + SLEN("--clients="); |
| 11044 | if (!requested_clients[0]) { |
| 11045 | (void)fprintf(stderr, "error: --clients requires a value\n\n"); |
| 11046 | cli_clients_print_list(stderr); |
| 11047 | return CLI_TRUE; |
| 11048 | } |
| 11049 | } else if (strcmp(argv[i], "--clients") == 0) { |
| 11050 | /* Bare `--clients` (and `--clients=help`/`list`) print the |
| 11051 | * vocabulary, including tokens users would not readily guess. */ |
| 11052 | cli_clients_print_list(stdout); |
| 11053 | return 0; |
| 11054 | } else if (strcmp(argv[i], "--skip-binary") == 0) { |
| 11055 | /* #1566: the mirror of --skip-config. Configure the agents, leave |
| 11056 | * the binary and PATH alone. */ |
| 11057 | skip_binary = true; |
| 11058 | } else if (strcmp(argv[i], "--force-binary") == 0) { |
| 11059 | force_binary = true; |
| 11060 | } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) { |
| 11061 | requested_bin_dir = argv[i] + SLEN("--dir="); |
| 11062 | if (!requested_bin_dir[0]) { |
| 11063 | (void)fprintf(stderr, "error: --dir requires a non-empty path\n"); |
| 11064 | return CLI_TRUE; |
| 11065 | } |
| 11066 | } else if (strcmp(argv[i], "--dir") == 0) { |
| 11067 | if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') { |
| 11068 | (void)fprintf(stderr, "error: --dir requires a non-empty path\n"); |
| 11069 | return CLI_TRUE; |
| 11070 | } |
| 11071 | requested_bin_dir = argv[++i]; |
| 11072 | } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 && |
| 11073 | strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) { |
| 11074 | (void)fprintf(stderr, "error: unknown install option: %s\n", argv[i]); |
| 11075 | return CLI_TRUE; |
| 11076 | } |
| 11077 | } |
no test coverage detected