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

Function cbm_cmd_uninstall

src/cli/cli.c:10955–11075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10953}
10954
10955int cbm_cmd_uninstall(int argc, char **argv) {
10956 parse_auto_answer(argc, argv);
10957 bool dry_run = false;
10958 /* An install into a custom --dir must be removable from that same dir:
10959 * without this, anyone who installed outside ~/.local/bin has no supported
10960 * uninstall path at all. Mirrors cbm_cmd_install's parsing. */
10961 const char *requested_bin_dir = NULL;
10962 for (int i = 0; i < argc; i++) {
10963 /* The public command dispatcher passes option-only argv, while the
10964 * long-standing direct API/tests include the subcommand at argv[0]. */
10965 if (i == 0 && strcmp(argv[i], "uninstall") == 0) {
10966 continue;
10967 }
10968 if (strcmp(argv[i], "--dry-run") == 0) {
10969 dry_run = true;
10970 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
10971 requested_bin_dir = argv[i] + SLEN("--dir=");
10972 if (!requested_bin_dir[0]) {
10973 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
10974 return CLI_TRUE;
10975 }
10976 } else if (strcmp(argv[i], "--dir") == 0) {
10977 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
10978 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
10979 return CLI_TRUE;
10980 }
10981 requested_bin_dir = argv[++i];
10982 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
10983 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
10984 (void)fprintf(stderr, "error: unknown uninstall option: %s\n", argv[i]);
10985 return CLI_TRUE;
10986 }
10987 }
10988
10989 const char *home = cbm_get_home_dir();
10990 if (!home) {
10991 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
10992 return CLI_TRUE;
10993 }
10994
10995 printf("codebase-memory-mcp uninstall\n\n");
10996
10997 g_agent_uninstall_errors = 0;
10998 cbm_detected_agents_t agents = cbm_detect_agents(home);
10999
11000 /* Confirm index removal outside the startup lock, but defer the mutation
11001 * until the final guarded activation. Dry-run never removes indexes. */
11002 bool delete_indexes = false;
11003 int index_count = count_db_indexes(home);
11004 if (index_count > 0) {
11005 printf("\nFound %d index(es):\n", index_count);
11006 cbm_list_indexes(home);
11007 if (prompt_yn("Delete these indexes?")) {
11008 if (dry_run) {
11009 printf("(dry-run — indexes would be deleted)\n");
11010 } else {
11011 delete_indexes = true;
11012 }

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