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

Function cbm_cmd_uninstall

src/cli/cli.c:11426–11570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11424}
11425
11426int cbm_cmd_uninstall(int argc, char **argv) {
11427 /* `uninstall --help` used to UNINSTALL.
11428 *
11429 * The top-level dispatcher matches the subcommand at argv[1] and hands the
11430 * rest here, so its own --help check never sees argv[2]. Nothing downstream
11431 * looked either, and --help is the one flag a person types precisely
11432 * BECAUSE they are not sure what a command does. It removed the binary and
11433 * every agent configuration (#1038).
11434 *
11435 * Checked before parse_auto_answer so a `-y` sitting elsewhere on the line
11436 * cannot auto-confirm the destruction we are trying to prevent. */
11437 for (int i = 0; i < argc; i++) {
11438 if (argv && argv[i] && (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)) {
11439 printf("Usage: codebase-memory-mcp uninstall [options]\n\n"
11440 "Removes the codebase-memory-mcp binary, its agent configurations and,\n"
11441 "with confirmation, its indexes. THIS IS DESTRUCTIVE.\n\n"
11442 "Options:\n"
11443 " --dry-run Show what would be removed, change nothing\n"
11444 " --dir=PATH Uninstall from a custom install directory\n"
11445 " -y, --yes Do not prompt for confirmation\n"
11446 " -h, --help Show this help and exit\n\n"
11447 "Run with --dry-run first if you are unsure.\n");
11448 return CLI_OK;
11449 }
11450 }
11451 parse_auto_answer(argc, argv);
11452 bool dry_run = false;
11453 /* An install into a custom --dir must be removable from that same dir:
11454 * without this, anyone who installed outside ~/.local/bin has no supported
11455 * uninstall path at all. Mirrors cbm_cmd_install's parsing. */
11456 const char *requested_bin_dir = NULL;
11457 for (int i = 0; i < argc; i++) {
11458 /* The public command dispatcher passes option-only argv, while the
11459 * long-standing direct API/tests include the subcommand at argv[0]. */
11460 if (i == 0 && strcmp(argv[i], "uninstall") == 0) {
11461 continue;
11462 }
11463 if (strcmp(argv[i], "--dry-run") == 0) {
11464 dry_run = true;
11465 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
11466 requested_bin_dir = argv[i] + SLEN("--dir=");
11467 if (!requested_bin_dir[0]) {
11468 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
11469 return CLI_TRUE;
11470 }
11471 } else if (strcmp(argv[i], "--dir") == 0) {
11472 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
11473 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
11474 return CLI_TRUE;
11475 }
11476 requested_bin_dir = argv[++i];
11477 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
11478 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
11479 (void)fprintf(stderr, "error: unknown uninstall option: %s\n", argv[i]);
11480 return CLI_TRUE;
11481 }
11482 }
11483

Callers 2

handle_subcommandFunction · 0.85
test_cli.cFile · 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