TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: OpenAPI-like interface definition language for CLIs?

1 点作者 mieubrisse超过 1 年前
Hey folks, I&#x27;ve been thinking recently about how CLIs are just functions, and the config (flags, envvars, config files) are just parameters.<p>Yet, I&#x27;ve never heard of an interface definition language for CLIs. It strikes me as potentially being very valuable:<p>- You could generate code that would allow the CLI to accept and handle the resolution of all three of envvars, flags, and config files (to enable full human and machine readability)<p>- The developer wouldn&#x27;t have to manually deal with generating the &#x27;PROPERTY1_2_SUBPROPERTY&#x27; syntax that 12-factor app development advocates for, but is a pain to understand<p>- It would allow for a formal API for the CLI, allowing for API breaks to be clear (for those who programmatically call the CLI)<p>- The idea of &quot;routes&quot; maps quite nicely to the &quot;cli $subcommand [$subcommand] $verb ...flags...&quot; pattern that docker and kubectl have set<p>- You could use it to generate language-specific CLI framework bindings, like Go&#x27;s Cobra<p>- You could do documentation generation<p>- You could do generation of language-specific bindings for calling the CLI, so that calling the CLI as a subprocess is a function call in another language (rather than subprocess.call([&quot;some&quot;,&quot;random&quot;,&quot;strings&quot;]))<p>- You can calculate if changes to the CLI break the API for someone (thereby allowing for automatic semver)<p>Has anyone heard of something like this? Or should I build it?

暂无评论

暂无评论