10000 cli.toJSON() by mmkal · Pull Request #98 · mmkal/trpc-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cli.toJSON() #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 10, 2025
Merged

cli.toJSON() #98

merged 8 commits into from
Jun 10, 2025

Conversation

mmkal
Copy link
Owner
@mmkal mmkal commented Jun 9, 2025

@thdxr I saw in one of your tweet replies you mentioned ability to export a CLI to json for generating website docs etc.

image

I had this in a local branch but never really bothered with it because 1) it really only operates on a commander Command rather than anything trpc-cli specific and 2) it's pretty trivial to implement in userland (you can get the commander Command from trpc-cli too) - but I don't see it being a problem/difficult to maintain.

Is this actually useful enough vs you just doing it yourself? you can already do:

const myProgram = myCli.buildProgram() as import('commander').Command

const myJsonThing = {name: myProgram.name(), description, myProgram.description(), ...}

Note: this exports the cli to json, not the trpc router. trpc-to-json is something this library more or less does internally but and could in theory be extracted to build trpc-to-openapi type things too, but designing for use other than for CLIs would take more work.

Copy link
pkg-pr-new bot commented Jun 10, 2025

Open in StackBlitz

npm i https://pkg.pr.new/mmkal/trpc-cli@98

commit: 5064747

@mmkal mmkal merged commit 7461d81 into main Jun 10, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0