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

Function cbm_cmd_install

src/cli/cli.c:9474–9785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9472}
9473
9474int cbm_cmd_install(int argc, char **argv) {
9475 parse_auto_answer(argc, argv);
9476 bool dry_run = false;
9477 bool force = false;
9478 bool plan = false;
9479 bool reset_indexes = false;
9480 bool skip_config = false;
9481 const char *requested_bin_dir = NULL;
9482 for (int i = 0; i < argc; i++) {
9483 if (strcmp(argv[i], "--dry-run") == 0) {
9484 dry_run = true;
9485 } else if (strcmp(argv[i], "--force") == 0) {
9486 force = true;
9487 } else if (strcmp(argv[i], "--plan") == 0) {
9488 plan = true;
9489 } else if (strcmp(argv[i], "--reset-indexes") == 0) {
9490 reset_indexes = true;
9491 } else if (strcmp(argv[i], "--skip-config") == 0) {
9492 skip_config = true;
9493 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
9494 requested_bin_dir = argv[i] + SLEN("--dir=");
9495 if (!requested_bin_dir[0]) {
9496 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
9497 return CLI_TRUE;
9498 }
9499 } else if (strcmp(argv[i], "--dir") == 0) {
9500 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
9501 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
9502 return CLI_TRUE;
9503 }
9504 requested_bin_dir = argv[++i];
9505 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
9506 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
9507 (void)fprintf(stderr, "error: unknown install option: %s\n", argv[i]);
9508 return CLI_TRUE;
9509 }
9510 }
9511
9512 const char *home = cbm_get_home_dir();
9513 if (!home) {
9514 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
9515 return CLI_TRUE;
9516 }
9517
9518 char bin_dir[CLI_BUF_1K];
9519 int bin_dir_length = requested_bin_dir
9520 ? snprintf(bin_dir, sizeof(bin_dir), "%s", requested_bin_dir)
9521 : snprintf(bin_dir, sizeof(bin_dir), "%s/.local/bin", home);
9522 if (bin_dir_length <= 0 || (size_t)bin_dir_length >= sizeof(bin_dir)) {
9523 (void)fprintf(stderr, "error: install directory path is too long\n");
9524 return CLI_TRUE;
9525 }
9526 cbm_normalize_path_sep(bin_dir);
9527 char bin_target[CLI_BUF_1K];
9528#ifdef _WIN32
9529 int target_length =
9530 snprintf(bin_target, sizeof(bin_target), "%s/codebase-memory-mcp.exe", bin_dir);
9531#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