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

Function cbm_cmd_update

src/cli/cli.c:13342–13576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13340}
13341
13342int cbm_cmd_update(int argc, char **argv) {
13343 parse_auto_answer(argc, argv);
13344
13345 bool dry_run = false;
13346 bool force = false;
13347 bool legacy_variant_flag = false;
13348 for (int i = 0; i < argc; i++) {
13349 if (strcmp(argv[i], "--dry-run") == 0) {
13350 dry_run = true;
13351 } else if (strcmp(argv[i], "--force") == 0) {
13352 force = true;
13353 } else if (strcmp(argv[i], "--ui") == 0 || strcmp(argv[i], "--standard") == 0) {
13354 /* v0.10.2 deleted the ui/standard chooser and, with it, these flags —
13355 * which turned `update --ui` from a working command into a hard
13356 * error for everyone who had it in a script, an alias, or muscle
13357 * memory (#1544). Removing a CHOICE is fine; removing the WORDS
13358 * people type is a break we owe them nothing for. Accept both,
13359 * ignore them, and say once why they no longer mean anything. */
13360 legacy_variant_flag = true;
13361 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
13362 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
13363 (void)fprintf(stderr, "error: unknown update option: %s\n", argv[i]);
13364 return CLI_TRUE;
13365 }
13366 }
13367 if (legacy_variant_flag) {
13368 (void)fprintf(stderr, "note: --ui/--standard are accepted but no longer do anything; since "
13369 "v0.10.0 there is one build per platform and it always includes the "
13370 "graph UI.\n");
13371 }
13372
13373 /* #1566: we cannot update a binary a package manager owns, and pretending
13374 * otherwise is the dishonest-success pattern this project keeps fixing:
13375 * reporting that an update ran while changing nothing leaves the user
13376 * convinced they are current. Refuse, and name the command that WILL work. */
13377 {
13378 char self_path[CLI_BUF_1K] = {0};
13379 const char *home = cbm_get_home_dir();
13380 bool self_exact = home && cbm_detect_self_path(self_path, sizeof(self_path), home);
13381 char managed_dir[CLI_BUF_1K] = {0};
13382 if (self_exact && home) {
13383 snprintf(managed_dir, sizeof(managed_dir), "%s/.local/bin", home);
13384 }
13385 if (self_exact && cli_binary_is_externally_managed(self_path, true, managed_dir)) {
13386 const char *manager = cli_external_manager_name(self_path);
13387 (void)fprintf(stderr,
13388 "error: this binary is managed by %s, so `update` cannot replace it:\n"
13389 " %s\n",
13390 manager ? manager : "another installer", self_path);
13391 if (manager && strcmp(manager, "mise") == 0) {
13392 (void)fprintf(stderr, " update it with: mise upgrade codebase-memory-mcp\n");
13393 } else if (manager && strcmp(manager, "Homebrew") == 0) {
13394 (void)fprintf(stderr, " update it with: brew upgrade codebase-memory-mcp\n");
13395 } else if (manager && strcmp(manager, "FreeBSD pkg") == 0) {
13396 (void)fprintf(stderr, " update it with: pkg upgrade codebase-memory-mcp\n");
13397 } else {
13398 (void)fprintf(stderr, " update it through whichever tool installed it.\n");
13399 }

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