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

Function cbm_cmd_uninstall

src/cli/cli.c:10949–11069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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