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

Function cbm_cmd_config

src/cli/cli.c:2828–2908  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2826/* ── Config CLI subcommand ────────────────────────────────────── */
2827
2828int cbm_cmd_config(int argc, char **argv) {
2829 if (argc == 0) {
2830 printf("Usage: codebase-memory-mcp config <command> [args]\n\n");
2831 printf("Commands:\n");
2832 printf(" list Show all config values\n");
2833 printf(" get <key> Get a config value\n");
2834 printf(" set <key> <val> Set a config value\n");
2835 printf(" reset <key> Reset a key to default\n\n");
2836 printf("Config keys:\n");
2837 printf(" %-25s default=%-10s %s\n", CBM_CONFIG_AUTO_INDEX, "false",
2838 "Enable auto-indexing on MCP session start");
2839 printf(" %-25s default=%-10s %s\n", CBM_CONFIG_AUTO_INDEX_LIMIT, "50000",
2840 "Max files for auto-indexing new projects");
2841 printf(" %-25s default=%-10s %s\n", CBM_CONFIG_AUTO_WATCH, "true",
2842 "Register background git watcher on session connect");
2843 printf(" %-25s default=%-10s %s\n", CBM_CONFIG_UI_LANG, "auto",
2844 "Pin graph UI language: en, zh, or auto");
2845 return 0;
2846 }
2847
2848 const char *home = cbm_get_home_dir();
2849 if (!home) {
2850 (void)fprintf(stderr, "error: HOME not set (use USERPROFILE on Windows)\n");
2851 return CLI_TRUE;
2852 }
2853
2854 char cache_dir[CLI_BUF_1K];
2855 snprintf(cache_dir, sizeof(cache_dir), "%s", cbm_resolve_cache_dir());
2856
2857 cbm_config_t *cfg = cbm_config_open(cache_dir);
2858 if (!cfg) {
2859 (void)fprintf(stderr, "error: cannot open config database\n");
2860 return CLI_TRUE;
2861 }
2862
2863 int rc = 0;
2864 if (strcmp(argv[0], "list") == 0 || strcmp(argv[0], "ls") == 0) {
2865 printf("Configuration:\n");
2866 printf(" %-25s = %-10s\n", CBM_CONFIG_AUTO_INDEX,
2867 cbm_config_get(cfg, CBM_CONFIG_AUTO_INDEX, "false"));
2868 printf(" %-25s = %-10s\n", CBM_CONFIG_AUTO_INDEX_LIMIT,
2869 cbm_config_get(cfg, CBM_CONFIG_AUTO_INDEX_LIMIT, "50000"));
2870 printf(" %-25s = %-10s\n", CBM_CONFIG_AUTO_WATCH,
2871 cbm_config_get(cfg, CBM_CONFIG_AUTO_WATCH, "true"));
2872 printf(" %-25s = %-10s\n", CBM_CONFIG_UI_LANG,
2873 cbm_config_get(cfg, CBM_CONFIG_UI_LANG, "auto"));
2874 } else if (strcmp(argv[0], "get") == 0) {
2875 if (argc < MIN_ARGC_GET) {
2876 (void)fprintf(stderr, "Usage: config get <key>\n");
2877 rc = CLI_TRUE;
2878 } else {
2879 printf("%s\n", cbm_config_get(cfg, argv[CLI_SKIP_ONE], ""));
2880 }
2881 } else if (strcmp(argv[0], "set") == 0) {
2882 if (argc < MIN_ARGC_CMD) {
2883 (void)fprintf(stderr, "Usage: config set <key> <value>\n");
2884 rc = CLI_TRUE;
2885 } else {

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