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

Function cbm_cmd_uninstall

src/cli/cli.c:13002–13154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13000}
13001
13002int cbm_cmd_uninstall(int argc, char **argv) {
13003 /* `uninstall --help` used to UNINSTALL.
13004 *
13005 * The top-level dispatcher matches the subcommand at argv[1] and hands the
13006 * rest here, so its own --help check never sees argv[2]. Nothing downstream
13007 * looked either, and --help is the one flag a person types precisely
13008 * BECAUSE they are not sure what a command does. It removed the binary and
13009 * every agent configuration (#1038).
13010 *
13011 * Checked before parse_auto_answer so a `-y` sitting elsewhere on the line
13012 * cannot auto-confirm the destruction we are trying to prevent. */
13013 for (int i = 0; i < argc; i++) {
13014 if (argv && argv[i] && (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)) {
13015 printf(
13016 "Usage: codebase-memory-mcp uninstall [options]\n\n"
13017 "Removes the codebase-memory-mcp binary and its agent configurations.\n"
13018 "THIS IS DESTRUCTIVE. Project indexes are kept by default. An interactive\n"
13019 "terminal is asked separately; the default answer is to keep them.\n\n"
13020 "Options:\n"
13021 " --dry-run Show what would be removed, change nothing\n"
13022 " --dir=PATH Uninstall from a custom install directory\n"
13023 " --delete-indexes Also delete every project index (overrides --no)\n"
13024 " -y, --yes Do not prompt; indexes are kept unless explicitly deleted\n"
13025 " -n, --no Decline prompts; --delete-indexes still takes precedence\n"
13026 " -h, --help Show this help and exit\n\n"
13027 "Run with --dry-run first if you are unsure.\n");
13028 return CLI_OK;
13029 }
13030 }
13031 parse_auto_answer(argc, argv);
13032 bool dry_run = false;
13033 bool delete_indexes_requested = false;
13034 /* An install into a custom --dir must be removable from that same dir:
13035 * without this, anyone who installed outside ~/.local/bin has no supported
13036 * uninstall path at all. Mirrors cbm_cmd_install's parsing. */
13037 const char *requested_bin_dir = NULL;
13038 for (int i = 0; i < argc; i++) {
13039 /* The public command dispatcher passes option-only argv, while the
13040 * long-standing direct API/tests include the subcommand at argv[0]. */
13041 if (i == 0 && strcmp(argv[i], "uninstall") == 0) {
13042 continue;
13043 }
13044 if (strcmp(argv[i], "--dry-run") == 0) {
13045 dry_run = true;
13046 } else if (strcmp(argv[i], "--delete-indexes") == 0) {
13047 delete_indexes_requested = true;
13048 } else if (strncmp(argv[i], "--dir=", SLEN("--dir=")) == 0) {
13049 requested_bin_dir = argv[i] + SLEN("--dir=");
13050 if (!requested_bin_dir[0]) {
13051 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
13052 return CLI_TRUE;
13053 }
13054 } else if (strcmp(argv[i], "--dir") == 0) {
13055 if (i + 1 >= argc || !argv[i + 1] || !argv[i + 1][0] || argv[i + 1][0] == '-') {
13056 (void)fprintf(stderr, "error: --dir requires a non-empty path\n");
13057 return CLI_TRUE;
13058 }
13059 requested_bin_dir = argv[++i];

Callers 2

handle_subcommandFunction · 0.85
test_cli.cFile · 0.85

Tested by

no test coverage detected