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

Function cbm_cmd_uninstall

src/cli/cli.c:11364–11484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11362}
11363
11364int cbm_cmd_uninstall(int argc, char **argv) {
11365 parse_auto_answer(argc, argv);
11366 bool dry_run = false;
11367 /* An install into a custom --dir must be removable from that same dir:
11368 * without this, anyone who installed outside ~/.local/bin has no supported
11369 * uninstall path at all. Mirrors cbm_cmd_install's parsing. */
11370 const char *requested_bin_dir = NULL;
11371 for (int i = 0; i < argc; i++) {
11372 /* The public command dispatcher passes option-only argv, while the
11373 * long-standing direct API/tests include the subcommand at argv[0]. */
11374 if (i == 0 && strcmp(argv[i], "uninstall") == 0) {
11375 continue;
11376 }
11377 if (strcmp(argv[i], "--dry-run") == 0) {
11378 dry_run = true;
11379 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
11380 requested_bin_dir = argv[i] + SLEN("--dir=");
11381 if (!requested_bin_dir[0]) {
11382 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
11383 return CLI_TRUE;
11384 }
11385 } else if (strcmp(argv[i], "--dir") == 0) {
11386 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
11387 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
11388 return CLI_TRUE;
11389 }
11390 requested_bin_dir = argv[++i];
11391 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
11392 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
11393 (void)fprintf(stderr, "error: unknown uninstall option: %s\n", argv[i]);
11394 return CLI_TRUE;
11395 }
11396 }
11397
11398 const char *home = cbm_get_home_dir();
11399 if (!home) {
11400 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
11401 return CLI_TRUE;
11402 }
11403
11404 printf("codebase-memory-mcp uninstall\n\n");
11405
11406 g_agent_uninstall_errors = 0;
11407 cbm_detected_agents_t agents = cbm_detect_agents(home);
11408
11409 /* Confirm index removal outside the startup lock, but defer the mutation
11410 * until the final guarded activation. Dry-run never removes indexes. */
11411 bool delete_indexes = false;
11412 int index_count = count_db_indexes(home);
11413 if (index_count > 0) {
11414 printf("\nFound %d index(es):\n", index_count);
11415 cbm_list_indexes(home);
11416 if (prompt_yn("Delete these indexes?")) {
11417 if (dry_run) {
11418 printf("(dry-run — indexes would be deleted)\n");
11419 } else {
11420 delete_indexes = true;
11421 }

Callers 1

handle_subcommandFunction · 0.85

Calls 12

parse_auto_answerFunction · 0.85
cbm_get_home_dirFunction · 0.85
cbm_detect_agentsFunction · 0.85
count_db_indexesFunction · 0.85
cbm_list_indexesFunction · 0.85
prompt_ynFunction · 0.85
cbm_path_info_utf8Function · 0.85
cli_uninstall_activateFunction · 0.85
cli_activation_guardFunction · 0.85

Tested by

no test coverage detected