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

Function cbm_cmd_install

src/cli/cli.c:9418–9729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9416}
9417
9418int cbm_cmd_install(int argc, char **argv) {
9419 parse_auto_answer(argc, argv);
9420 bool dry_run = false;
9421 bool force = false;
9422 bool plan = false;
9423 bool reset_indexes = false;
9424 bool skip_config = false;
9425 const char *requested_bin_dir = NULL;
9426 for (int i = 0; i < argc; i++) {
9427 if (strcmp(argv[i], "--dry-run") == 0) {
9428 dry_run = true;
9429 } else if (strcmp(argv[i], "--force") == 0) {
9430 force = true;
9431 } else if (strcmp(argv[i], "--plan") == 0) {
9432 plan = true;
9433 } else if (strcmp(argv[i], "--reset-indexes") == 0) {
9434 reset_indexes = true;
9435 } else if (strcmp(argv[i], "--skip-config") == 0) {
9436 skip_config = true;
9437 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
9438 requested_bin_dir = argv[i] + SLEN("--dir=");
9439 if (!requested_bin_dir[0]) {
9440 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
9441 return CLI_TRUE;
9442 }
9443 } else if (strcmp(argv[i], "--dir") == 0) {
9444 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
9445 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
9446 return CLI_TRUE;
9447 }
9448 requested_bin_dir = argv[++i];
9449 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
9450 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
9451 (void)fprintf(stderr, "error: unknown install option: %s\n", argv[i]);
9452 return CLI_TRUE;
9453 }
9454 }
9455
9456 const char *home = cbm_get_home_dir();
9457 if (!home) {
9458 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
9459 return CLI_TRUE;
9460 }
9461
9462 char bin_dir[CLI_BUF_1K];
9463 int bin_dir_length = requested_bin_dir
9464 ? snprintf(bin_dir, sizeof(bin_dir), "%s", requested_bin_dir)
9465 : snprintf(bin_dir, sizeof(bin_dir), "%s/.local/bin", home);
9466 if (bin_dir_length <= 0 || (size_t)bin_dir_length >= sizeof(bin_dir)) {
9467 (void)fprintf(stderr, "error: install directory path is too long\n");
9468 return CLI_TRUE;
9469 }
9470 cbm_normalize_path_sep(bin_dir);
9471 char bin_target[CLI_BUF_1K];
9472#ifdef _WIN32
9473 int target_length =
9474 snprintf(bin_target, sizeof(bin_target), "%s/codebase-memory-mcp.exe", bin_dir);
9475#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