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

Function cbm_cmd_update

src/cli/cli.c:13682–13916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13680}
13681
13682int cbm_cmd_update(int argc, char **argv) {
13683 parse_auto_answer(argc, argv);
13684
13685 bool dry_run = false;
13686 bool force = false;
13687 bool legacy_variant_flag = false;
13688 for (int i = 0; i < argc; i++) {
13689 if (strcmp(argv[i], "--dry-run") == 0) {
13690 dry_run = true;
13691 } else if (strcmp(argv[i], "--force") == 0) {
13692 force = true;
13693 } else if (strcmp(argv[i], "--ui") == 0 || strcmp(argv[i], "--standard") == 0) {
13694 /* v0.10.2 deleted the ui/standard chooser and, with it, these flags —
13695 * which turned `update --ui` from a working command into a hard
13696 * error for everyone who had it in a script, an alias, or muscle
13697 * memory (#1544). Removing a CHOICE is fine; removing the WORDS
13698 * people type is a break we owe them nothing for. Accept both,
13699 * ignore them, and say once why they no longer mean anything. */
13700 legacy_variant_flag = true;
13701 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
13702 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
13703 (void)fprintf(stderr, "error: unknown update option: %s\n", argv[i]);
13704 return CLI_TRUE;
13705 }
13706 }
13707 if (legacy_variant_flag) {
13708 (void)fprintf(stderr, "note: --ui/--standard are accepted but no longer do anything; since "
13709 "v0.10.0 there is one build per platform and it always includes the "
13710 "graph UI.\n");
13711 }
13712
13713 /* #1566: we cannot update a binary a package manager owns, and pretending
13714 * otherwise is the dishonest-success pattern this project keeps fixing:
13715 * reporting that an update ran while changing nothing leaves the user
13716 * convinced they are current. Refuse, and name the command that WILL work. */
13717 {
13718 char self_path[CLI_BUF_1K] = {0};
13719 const char *home = cbm_get_home_dir();
13720 bool self_exact = home && cbm_detect_self_path(self_path, sizeof(self_path), home);
13721 char managed_dir[CLI_BUF_1K] = {0};
13722 if (self_exact && home) {
13723 snprintf(managed_dir, sizeof(managed_dir), "%s/.local/bin", home);
13724 }
13725 if (self_exact && cli_binary_is_externally_managed(self_path, true, managed_dir)) {
13726 const char *manager = cli_external_manager_name(self_path);
13727 (void)fprintf(stderr,
13728 "error: this binary is managed by %s, so `update` cannot replace it:\n"
13729 " %s\n",
13730 manager ? manager : "another installer", self_path);
13731 if (manager && strcmp(manager, "mise") == 0) {
13732 (void)fprintf(stderr, " update it with: mise upgrade codebase-memory-mcp\n");
13733 } else if (manager && strcmp(manager, "Homebrew") == 0) {
13734 (void)fprintf(stderr, " update it with: brew upgrade codebase-memory-mcp\n");
13735 } else if (manager && strcmp(manager, "FreeBSD pkg") == 0) {
13736 (void)fprintf(stderr, " update it with: pkg upgrade codebase-memory-mcp\n");
13737 } else {
13738 (void)fprintf(stderr, " update it through whichever tool installed it.\n");
13739 }

Callers 2

handle_subcommandFunction · 0.85
test_cli.cFile · 0.85

Calls 13

parse_auto_answerFunction · 0.85
cbm_get_home_dirFunction · 0.85
cbm_detect_self_pathFunction · 0.85
check_already_latestFunction · 0.85
detect_osFunction · 0.85
detect_archFunction · 0.85
build_update_urlFunction · 0.85
cbm_mkdir_pFunction · 0.85
download_verify_installFunction · 0.85

Tested by

no test coverage detected