Conversation
Closes bcdxn#23 Co-Authored-By: Claude <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
bcdxn
left a comment
There was a problem hiding this comment.
As I've been thinking through this: I don't think I actually want ocli itself to execute a CLI binary to discover its OpenCLI document.
The original __opencli adapter was intended primarily as a bridge for existing/code-first CLIs to produce an OpenCLI document. Once you have that document, I want ocli or other tools in the ecosystem to operate on the document itself rather than needing to know how it was produced.
So I'm leaning toward keeping the flow explicit:
mycli __opencli > opencli.yaml
ocli gen docs --path opencli.yamlIt keeps a pretty clean separation between "produce an OpenCLI document" and "operate on an OpenCLI document." It also means --path always means a path to an OpenCLI document rather than sometimes a string path, sometimes a binary executable.
This way also makes me less concerned about whether we need to standardize a bunch of alternative discovery mechanisms. __opencli can simply be the machine-facing convention for adapters, while the actual OpenCLI tooling continues to consume the resulting document.
If you remove the public-command changes and instead add an option to customize the name of the existing __opencli command, while keeping __opencli as the default, I'm happy to accept the PR.
Closes #23
Adapters
ocobraandourfavegain aWithPublicCommand(name)option that attaches a visible subcommand (e.g.docgen) alongside the hidden__opencli. Both commands share one implementation and now accept--format yaml|jsonin addition to-o/--out. Generator commands are marked via cobraAnnotations/ urfaveMetadataso the tree walk skips them regardless of name.__opencliis unchanged and always attached, so existing users are unaffected.ocli
ocli check,ocli gen docs, andocli gen clinow accept a CLI binary in place of a spec file. When the path has no.json/.yaml/.ymlextension and is executable,ocliruns<binary> __openclifirst, then<binary> docgen, and uses the first document produced. This supports CLIs that expose only one of the two commands (clidoc, for instance, exposes both).Spec loading for the three commands is consolidated into one helper, replacing three copies of the same stat/extension/read logic.
Docs and tests
ocli.ocs.yamlargument descriptions updated; generated CLI code and docs regenerated.--format json, and is excluded from the document (both adapters); binary fallback todocgen; error listing tried commands.go generate ./...andgo test ./...pass.