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

Function cbm_cmd_config

src/cli/cli.c:6513–6596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6511/* ── Config CLI subcommand ────────────────────────────────────── */
6512
6513int cbm_cmd_config(int argc, char **argv) {
6514 /* NULL argv with a nonzero argc previously slipped past this guard (the
6515 * inner `argv &&` shielded only the help comparison) and dereferenced
6516 * argv[0] below -- caught by the clang-analyzer lane. */
6517 if (argc == 0 || !argv || strcmp(argv[0], "--help") == 0 || strcmp(argv[0], "-h") == 0) {
6518 printf("Usage: codebase-memory-mcp config <command> [args]\n\n");
6519 printf("Commands:\n");
6520 printf(" list Show all config values\n");
6521 printf(" get <key> Get a config value\n");
6522 printf(" set <key> <val> Set a config value\n");
6523 printf(" reset <key> Reset a key to default\n\n");
6524 printf("Config keys:\n");
6525 printf(" %-25s default=%-10s %s\n", CBM_CONFIG_AUTO_INDEX, "false",
6526 "Enable auto-indexing on MCP session start");
6527 printf(" %-25s default=%-10s %s\n", CBM_CONFIG_AUTO_INDEX_LIMIT, "50000",
6528 "Max files for auto-indexing new projects");
6529 printf(" %-25s default=%-10s %s\n", CBM_CONFIG_AUTO_WATCH, "true",
6530 "Register background git watcher on session connect");
6531 printf(" %-25s default=%-10s %s\n", CBM_CONFIG_UI_LANG, "auto",
6532 "Pin graph UI language: en, zh, or auto");
6533 return 0;
6534 }
6535
6536 const char *home = cbm_get_home_dir();
6537 if (!home) {
6538 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
6539 return CLI_TRUE;
6540 }
6541
6542 char cache_dir[CLI_BUF_1K];
6543 snprintf(cache_dir, sizeof(cache_dir), "%s", cbm_resolve_cache_dir());
6544
6545 cbm_config_t *cfg = cbm_config_open(cache_dir);
6546 if (!cfg) {
6547 (void)fprintf(stderr, "error: cannot open config database\n");
6548 return CLI_TRUE;
6549 }
6550
6551 int rc = 0;
6552 if (strcmp(argv[0], "list") == 0 || strcmp(argv[0], "ls") == 0) {
6553 printf("Configuration:\n");
6554 printf(" %-25s = %-10s\n", CBM_CONFIG_AUTO_INDEX,
6555 cbm_config_get(cfg, CBM_CONFIG_AUTO_INDEX, "false"));
6556 printf(" %-25s = %-10s\n", CBM_CONFIG_AUTO_INDEX_LIMIT,
6557 cbm_config_get(cfg, CBM_CONFIG_AUTO_INDEX_LIMIT, "50000"));
6558 printf(" %-25s = %-10s\n", CBM_CONFIG_AUTO_WATCH,
6559 cbm_config_get(cfg, CBM_CONFIG_AUTO_WATCH, "true"));
6560 printf(" %-25s = %-10s\n", CBM_CONFIG_UI_LANG,
6561 cbm_config_get(cfg, CBM_CONFIG_UI_LANG, "auto"));
6562 } else if (strcmp(argv[0], "get") == 0) {
6563 if (argc < MIN_ARGC_GET) {
6564 (void)fprintf(stderr, "Usage: config get <key>\n");
6565 rc = CLI_TRUE;
6566 } else {
6567 printf("%s\n", cbm_config_get(cfg, argv[CLI_SKIP_ONE], ""));
6568 }
6569 } else if (strcmp(argv[0], "set") == 0) {
6570 if (argc < MIN_ARGC_CMD) {

Callers 1

handle_subcommandFunction · 0.85

Calls 7

cbm_get_home_dirFunction · 0.85
cbm_resolve_cache_dirFunction · 0.85
cbm_config_openFunction · 0.85
cbm_config_getFunction · 0.85
cbm_config_setFunction · 0.85
cbm_config_deleteFunction · 0.85
cbm_config_closeFunction · 0.85

Tested by

no test coverage detected