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

Function cbm_cmd_uninstall

src/cli/cli.c:10905–11025  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10903}
10904
10905int cbm_cmd_uninstall(int argc, char **argv) {
10906 parse_auto_answer(argc, argv);
10907 bool dry_run = false;
10908 /* An install into a custom --dir must be removable from that same dir:
10909 * without this, anyone who installed outside ~/.local/bin has no supported
10910 * uninstall path at all. Mirrors cbm_cmd_install's parsing. */
10911 const char *requested_bin_dir = NULL;
10912 for (int i = 0; i < argc; i++) {
10913 /* The public command dispatcher passes option-only argv, while the
10914 * long-standing direct API/tests include the subcommand at argv[0]. */
10915 if (i == 0 && strcmp(argv[i], "uninstall") == 0) {
10916 continue;
10917 }
10918 if (strcmp(argv[i], "--dry-run") == 0) {
10919 dry_run = true;
10920 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
10921 requested_bin_dir = argv[i] + SLEN("--dir=");
10922 if (!requested_bin_dir[0]) {
10923 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
10924 return CLI_TRUE;
10925 }
10926 } else if (strcmp(argv[i], "--dir") == 0) {
10927 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
10928 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
10929 return CLI_TRUE;
10930 }
10931 requested_bin_dir = argv[++i];
10932 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
10933 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
10934 (void)fprintf(stderr, "error: unknown uninstall option: %s\n", argv[i]);
10935 return CLI_TRUE;
10936 }
10937 }
10938
10939 const char *home = cbm_get_home_dir();
10940 if (!home) {
10941 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
10942 return CLI_TRUE;
10943 }
10944
10945 printf("codebase-memory-mcp uninstall\n\n");
10946
10947 g_agent_uninstall_errors = 0;
10948 cbm_detected_agents_t agents = cbm_detect_agents(home);
10949
10950 /* Confirm index removal outside the startup lock, but defer the mutation
10951 * until the final guarded activation. Dry-run never removes indexes. */
10952 bool delete_indexes = false;
10953 int index_count = count_db_indexes(home);
10954 if (index_count > 0) {
10955 printf("\nFound %d index(es):\n", index_count);
10956 cbm_list_indexes(home);
10957 if (prompt_yn("Delete these indexes?")) {
10958 if (dry_run) {
10959 printf("(dry-run — indexes would be deleted)\n");
10960 } else {
10961 delete_indexes = true;
10962 }

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