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

Function cbm_cmd_update

src/cli/cli.c:4381–4490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4379}
4380
4381int cbm_cmd_update(int argc, char **argv) {
4382 parse_auto_answer(argc, argv);
4383
4384 bool dry_run = false;
4385 bool force = false;
4386 int variant_flag = 0; /* 0 = ask, 1 = standard, 2 = ui */
4387 for (int i = 0; i < argc; i++) {
4388 if (strcmp(argv[i], "--dry-run") == 0) {
4389 dry_run = true;
4390 } else if (strcmp(argv[i], "--standard") == 0) {
4391 variant_flag = VARIANT_A;
4392 } else if (strcmp(argv[i], "--ui") == 0) {
4393 variant_flag = VARIANT_B;
4394 } else if (strcmp(argv[i], "--force") == 0) {
4395 force = true;
4396 }
4397 }
4398
4399 const char *home = cbm_get_home_dir();
4400 if (!home) {
4401 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
4402 return CLI_TRUE;
4403 }
4404
4405 printf("codebase-memory-mcp update (current: %s)\n\n", CBM_VERSION);
4406
4407 /* Version check — skip download if already on latest (not in dry-run). */
4408 if (!force && !dry_run && check_already_latest()) {
4409 return 0;
4410 }
4411
4412 /* Step 1: Check for existing indexes */
4413 if (update_clear_indexes(home, dry_run) != 0) {
4414 return CLI_TRUE;
4415 }
4416
4417 /* Step 2: Determine variant */
4418 int want_ui_rc = select_update_variant(variant_flag);
4419 if (want_ui_rc < 0) {
4420 return CLI_TRUE;
4421 }
4422 bool want_ui = (want_ui_rc == CLI_TRUE);
4423 const char *variant = want_ui ? "ui-" : "";
4424 const char *variant_label = want_ui ? "ui" : "standard";
4425
4426 const char *os = detect_os();
4427 const char *arch = detect_arch();
4428 const char *ext = strcmp(os, "windows") == 0 ? "zip" : "tar.gz";
4429
4430 char url[CLI_BUF_512];
4431 build_update_url(url, sizeof(url), os, arch, ext, want_ui);
4432
4433 if (dry_run) {
4434 printf("\nWould download %s binary for %s/%s ...\n", variant_label, os, arch);
4435 } else {
4436 printf("\nDownloading %s binary for %s/%s ...\n", variant_label, os, arch);
4437 }
4438 printf(" %s\n", url);

Callers 1

handle_subcommandFunction · 0.85

Calls 13

parse_auto_answerFunction · 0.85
cbm_get_home_dirFunction · 0.85
check_already_latestFunction · 0.85
update_clear_indexesFunction · 0.85
select_update_variantFunction · 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
cbm_macos_adhoc_signFunction · 0.85

Tested by

no test coverage detected