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

Function cbm_cli_print_tool_help

src/cli/cli.c:12731–12787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12729}
12730
12731int cbm_cli_print_tool_help(const char *tool_name) {
12732 const char *schema_str = cbm_mcp_tool_input_schema(tool_name);
12733 if (!schema_str) {
12734 return CLI_ERR;
12735 }
12736
12737 yyjson_doc *doc = yyjson_read(schema_str, strlen(schema_str), 0);
12738 yyjson_val *root = doc ? yyjson_doc_get_root(doc) : NULL;
12739 yyjson_val *props = root ? yyjson_obj_get(root, "properties") : NULL;
12740 yyjson_val *required = root ? yyjson_obj_get(root, "required") : NULL;
12741
12742 printf("Usage:\n");
12743 printf(" codebase-memory-mcp cli %s --flag value [--flag2 value2 ...]\n", tool_name);
12744 printf(" codebase-memory-mcp cli %s --args-file <path-to-json>\n", tool_name);
12745 printf(" echo '<json>' | codebase-memory-mcp cli %s\n", tool_name);
12746 printf(" codebase-memory-mcp cli %s '<raw-json-args>'\n", tool_name);
12747
12748 printf("\nFlags:\n");
12749 if (props && yyjson_is_obj(props)) {
12750 yyjson_obj_iter iter;
12751 yyjson_obj_iter_init(props, &iter);
12752 yyjson_val *pkey;
12753 while ((pkey = yyjson_obj_iter_next(&iter)) != NULL) {
12754 yyjson_val *pval = yyjson_obj_iter_get_val(pkey);
12755 const char *name = yyjson_get_str(pkey);
12756 if (!name) {
12757 continue;
12758 }
12759 const char *type = "string";
12760 const char *desc = "";
12761 if (yyjson_is_obj(pval)) {
12762 yyjson_val *t = yyjson_obj_get(pval, "type");
12763 if (t && yyjson_is_str(t)) {
12764 type = yyjson_get_str(t);
12765 }
12766 yyjson_val *d = yyjson_obj_get(pval, "description");
12767 if (d && yyjson_is_str(d)) {
12768 desc = yyjson_get_str(d);
12769 }
12770 }
12771 char flag[CLI_BUF_256];
12772 snprintf(flag, sizeof(flag), "%s", name);
12773 cli_snake_to_kebab(flag);
12774 bool req = cli_schema_required_has(required, name);
12775 printf(" --%s <%s>%s", flag, type, req ? " [required]" : "");
12776 if (desc[0]) {
12777 printf(" %s", desc);
12778 }
12779 printf("\n");
12780 }
12781 }
12782
12783 if (doc) {
12784 yyjson_doc_free(doc);
12785 }
12786 return CLI_OK;
12787}

Callers 2

run_cliFunction · 0.85
test_cli.cFile · 0.85

Calls 3

cli_snake_to_kebabFunction · 0.85
cli_schema_required_hasFunction · 0.85

Tested by

no test coverage detected