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:12750–12806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12748}
12749
12750int cbm_cli_print_tool_help(const char *tool_name) {
12751 const char *schema_str = cbm_mcp_tool_input_schema(tool_name);
12752 if (!schema_str) {
12753 return CLI_ERR;
12754 }
12755
12756 yyjson_doc *doc = yyjson_read(schema_str, strlen(schema_str), 0);
12757 yyjson_val *root = doc ? yyjson_doc_get_root(doc) : NULL;
12758 yyjson_val *props = root ? yyjson_obj_get(root, "properties") : NULL;
12759 yyjson_val *required = root ? yyjson_obj_get(root, "required") : NULL;
12760
12761 printf("Usage:\n");
12762 printf(" codebase-memory-mcp cli %s --flag value [--flag2 value2 ...]\n", tool_name);
12763 printf(" codebase-memory-mcp cli %s --args-file <path-to-json>\n", tool_name);
12764 printf(" echo '<json>' | codebase-memory-mcp cli %s\n", tool_name);
12765 printf(" codebase-memory-mcp cli %s '<raw-json-args>'\n", tool_name);
12766
12767 printf("\nFlags:\n");
12768 if (props && yyjson_is_obj(props)) {
12769 yyjson_obj_iter iter;
12770 yyjson_obj_iter_init(props, &iter);
12771 yyjson_val *pkey;
12772 while ((pkey = yyjson_obj_iter_next(&iter)) != NULL) {
12773 yyjson_val *pval = yyjson_obj_iter_get_val(pkey);
12774 const char *name = yyjson_get_str(pkey);
12775 if (!name) {
12776 continue;
12777 }
12778 const char *type = "string";
12779 const char *desc = "";
12780 if (yyjson_is_obj(pval)) {
12781 yyjson_val *t = yyjson_obj_get(pval, "type");
12782 if (t && yyjson_is_str(t)) {
12783 type = yyjson_get_str(t);
12784 }
12785 yyjson_val *d = yyjson_obj_get(pval, "description");
12786 if (d && yyjson_is_str(d)) {
12787 desc = yyjson_get_str(d);
12788 }
12789 }
12790 char flag[CLI_BUF_256];
12791 snprintf(flag, sizeof(flag), "%s", name);
12792 cli_snake_to_kebab(flag);
12793 bool req = cli_schema_required_has(required, name);
12794 printf(" --%s <%s>%s", flag, type, req ? " [required]" : "");
12795 if (desc[0]) {
12796 printf(" %s", desc);
12797 }
12798 printf("\n");
12799 }
12800 }
12801
12802 if (doc) {
12803 yyjson_doc_free(doc);
12804 }
12805 return CLI_OK;
12806}

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