MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_cmd_install

Function cbm_cmd_install

src/cli/cli.c:9368–9679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9366}
9367
9368int cbm_cmd_install(int argc, char **argv) {
9369 parse_auto_answer(argc, argv);
9370 bool dry_run = false;
9371 bool force = false;
9372 bool plan = false;
9373 bool reset_indexes = false;
9374 bool skip_config = false;
9375 const char *requested_bin_dir = NULL;
9376 for (int i = 0; i < argc; i++) {
9377 if (strcmp(argv[i], "--dry-run") == 0) {
9378 dry_run = true;
9379 } else if (strcmp(argv[i], "--force") == 0) {
9380 force = true;
9381 } else if (strcmp(argv[i], "--plan") == 0) {
9382 plan = true;
9383 } else if (strcmp(argv[i], "--reset-indexes") == 0) {
9384 reset_indexes = true;
9385 } else if (strcmp(argv[i], "--skip-config") == 0) {
9386 skip_config = true;
9387 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
9388 requested_bin_dir = argv[i] + SLEN("--dir=");
9389 if (!requested_bin_dir[0]) {
9390 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
9391 return CLI_TRUE;
9392 }
9393 } else if (strcmp(argv[i], "--dir") == 0) {
9394 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
9395 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
9396 return CLI_TRUE;
9397 }
9398 requested_bin_dir = argv[++i];
9399 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
9400 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
9401 (void)fprintf(stderr, "error: unknown install option: %s\n", argv[i]);
9402 return CLI_TRUE;
9403 }
9404 }
9405
9406 const char *home = cbm_get_home_dir();
9407 if (!home) {
9408 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
9409 return CLI_TRUE;
9410 }
9411
9412 char bin_dir[CLI_BUF_1K];
9413 int bin_dir_length = requested_bin_dir
9414 ? snprintf(bin_dir, sizeof(bin_dir), "%s", requested_bin_dir)
9415 : snprintf(bin_dir, sizeof(bin_dir), "%s/.local/bin", home);
9416 if (bin_dir_length <= 0 || (size_t)bin_dir_length >= sizeof(bin_dir)) {
9417 (void)fprintf(stderr, "error: install directory path is too long\n");
9418 return CLI_TRUE;
9419 }
9420 cbm_normalize_path_sep(bin_dir);
9421 char bin_target[CLI_BUF_1K];
9422#ifdef _WIN32
9423 int target_length =
9424 snprintf(bin_target, sizeof(bin_target), "%s/codebase-memory-mcp.exe", bin_dir);
9425#else

Callers 1

handle_subcommandFunction · 0.85

Calls 15

parse_auto_answerFunction · 0.85
cbm_get_home_dirFunction · 0.85
cbm_normalize_path_sepFunction · 0.85
cbm_detect_self_pathFunction · 0.85
cbm_path_info_utf8Function · 0.85
cbm_same_fileFunction · 0.85
prompt_ynFunction · 0.85
cbm_is_dirFunction · 0.85
cbm_tmpdirFunction · 0.85
cbm_mkdtempFunction · 0.85

Tested by

no test coverage detected