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

Function cbm_cmd_uninstall

src/cli/cli.c:12748–12907  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12746}
12747
12748int cbm_cmd_uninstall(int argc, char **argv) {
12749 /* `uninstall --help` used to UNINSTALL.
12750 *
12751 * The top-level dispatcher matches the subcommand at argv[1] and hands the
12752 * rest here, so its own --help check never sees argv[2]. Nothing downstream
12753 * looked either, and --help is the one flag a person types precisely
12754 * BECAUSE they are not sure what a command does. It removed the binary and
12755 * every agent configuration (#1038).
12756 *
12757 * Checked before parse_auto_answer so a `-y` sitting elsewhere on the line
12758 * cannot auto-confirm the destruction we are trying to prevent. */
12759 for (int i = 0; i < argc; i++) {
12760 if (argv && argv[i] && (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)) {
12761 printf("Usage: codebase-memory-mcp uninstall [options]\n\n"
12762 "Removes the codebase-memory-mcp binary, its agent configurations and,\n"
12763 "with confirmation, its indexes. THIS IS DESTRUCTIVE.\n\n"
12764 "Options:\n"
12765 " --dry-run Show what would be removed, change nothing\n"
12766 " --dir=PATH Uninstall from a custom install directory\n"
12767 " -y, --yes Do not prompt for confirmation\n"
12768 " -h, --help Show this help and exit\n\n"
12769 "Run with --dry-run first if you are unsure.\n");
12770 return CLI_OK;
12771 }
12772 }
12773 parse_auto_answer(argc, argv);
12774 bool dry_run = false;
12775 /* An install into a custom --dir must be removable from that same dir:
12776 * without this, anyone who installed outside ~/.local/bin has no supported
12777 * uninstall path at all. Mirrors cbm_cmd_install's parsing. */
12778 const char *requested_bin_dir = NULL;
12779 for (int i = 0; i < argc; i++) {
12780 /* The public command dispatcher passes option-only argv, while the
12781 * long-standing direct API/tests include the subcommand at argv[0]. */
12782 if (i == 0 && strcmp(argv[i], "uninstall") == 0) {
12783 continue;
12784 }
12785 if (strcmp(argv[i], "--dry-run") == 0) {
12786 dry_run = true;
12787 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
12788 requested_bin_dir = argv[i] + SLEN("--dir=");
12789 if (!requested_bin_dir[0]) {
12790 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
12791 return CLI_TRUE;
12792 }
12793 } else if (strcmp(argv[i], "--dir") == 0) {
12794 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
12795 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
12796 return CLI_TRUE;
12797 }
12798 requested_bin_dir = argv[++i];
12799 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
12800 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
12801 (void)fprintf(stderr, "error: unknown uninstall option: %s\n", argv[i]);
12802 return CLI_TRUE;
12803 }
12804 }
12805

Callers 2

handle_subcommandFunction · 0.85
test_cli.cFile · 0.85

Calls 15

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_normalize_path_sepFunction · 0.85
cbm_path_info_utf8Function · 0.85

Tested by

no test coverage detected