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

Function handle_subcommand

src/main.c:1277–1325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1275}
1276
1277static int handle_subcommand(int argc, char **argv, cbm_project_lock_manager_t *project_locks,
1278 main_local_maintenance_context_t *maintenance_context) {
1279 /* First scan: global flags */
1280 for (int i = SKIP_ONE; i < argc; i++) {
1281 if (strcmp(argv[i], "--profile") == 0) {
1282 cbm_profile_enable();
1283 }
1284 }
1285 for (int i = SKIP_ONE; i < argc; i++) {
1286 if (strcmp(argv[i], "--version") == 0) {
1287 printf("codebase-memory-mcp %s\n", CBM_VERSION);
1288 return 0;
1289 }
1290 if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
1291 print_help();
1292 return 0;
1293 }
1294 if (strcmp(argv[i], "allow-root") == 0) {
1295 return main_run_allow_root(argc - i - SKIP_ONE, argv + i + SKIP_ONE);
1296 }
1297 if (strcmp(argv[i], "cli") == 0) {
1298 cbm_mem_init_with_cap(cbm_mem_ram_fraction_for_total(cbm_system_info().total_ram),
1299 cbm_index_worker_memory_budget_bytes());
1300 return run_cli(argc - i - SKIP_ONE, argv + i + SKIP_ONE, project_locks,
1301 maintenance_context);
1302 }
1303 if (strcmp(argv[i], "hook-augment") == 0) {
1304 cbm_mem_init(cbm_mem_ram_fraction_for_total(cbm_system_info().total_ram));
1305 return cbm_cmd_hook_augment(argc - i - SKIP_ONE, argv + i + SKIP_ONE);
1306 }
1307 if (strcmp(argv[i], "test-impact") == 0) {
1308 cbm_mem_init(cbm_mem_ram_fraction_for_total(cbm_system_info().total_ram));
1309 return cbm_test_impact_cli(argc - i - SKIP_ONE, argv + i + SKIP_ONE);
1310 }
1311 if (strcmp(argv[i], "install") == 0) {
1312 return cbm_cmd_install(argc - i - SKIP_ONE, argv + i + SKIP_ONE);
1313 }
1314 if (strcmp(argv[i], "uninstall") == 0) {
1315 return cbm_cmd_uninstall(argc - i - SKIP_ONE, argv + i + SKIP_ONE);
1316 }
1317 if (strcmp(argv[i], "update") == 0) {
1318 return cbm_cmd_update(argc - i - SKIP_ONE, argv + i + SKIP_ONE);
1319 }
1320 if (strcmp(argv[i], "config") == 0) {
1321 return cbm_cmd_config(argc - i - SKIP_ONE, argv + i + SKIP_ONE);
1322 }
1323 }
1324 return CBM_NOT_FOUND;
1325}
1326
1327/* Parse --ui= and --port= into a per-field daemon mutation. */
1328static uint8_t parse_ui_flags(int argc, char **argv, bool *ui_enabled, int *ui_port,

Callers 1

mainFunction · 0.85

Calls 15

cbm_profile_enableFunction · 0.85
print_helpFunction · 0.85
main_run_allow_rootFunction · 0.85
cbm_mem_init_with_capFunction · 0.85
cbm_system_infoFunction · 0.85
cbm_mem_initFunction · 0.85
cbm_cmd_hook_augmentFunction · 0.85
cbm_test_impact_cliFunction · 0.85
cbm_cmd_installFunction · 0.85
cbm_cmd_uninstallFunction · 0.85

Tested by

no test coverage detected