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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Docli – A declarative language for command-line interfaces in Go

131 点作者 celicoo大约 6 年前

15 条评论

sametmax大约 6 年前
I used to love doctopt, but with usage your realise:<p>- i18n is made hard<p>- syntax errors are not caught by tooling<p>- you don&#x27;t get automatic args checking or env var override<p>Eventually, a well made programmative API is better.
评论 #19442382 未加载
评论 #19447244 未加载
评论 #19443049 未加载
hwj大约 6 年前
This is a Go library that parses a usage string into an AST.
评论 #19442588 未加载
评论 #19447425 未加载
评论 #19442458 未加载
ilovecaching大约 6 年前
I still feel that cobra and docopt are ungoish despite the author of cobra getting hired on. There&#x27;s simply too much magic to both of them. I would much rather they improve flags, which is what I use. It really doesn&#x27;t take that much with flags to add subcommands, etc, but it could be made better.
评论 #19445396 未加载
评论 #19446015 未加载
deforciant大约 6 年前
For servers I prefer using: <a href="https:&#x2F;&#x2F;github.com&#x2F;alecthomas&#x2F;kingpin" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alecthomas&#x2F;kingpin</a>, allows you to really nicely expand based on main arguments with flags. Also, setting defaults is a joy.<p>For CLIs - <a href="https:&#x2F;&#x2F;github.com&#x2F;spf13&#x2F;cobra" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;spf13&#x2F;cobra</a>.<p>However, will definitely try out Docli whenever I start building something new :)
thanatos_dem大约 6 年前
Seems like Cobra is pretty well established in this space - <a href="https:&#x2F;&#x2F;github.com&#x2F;spf13&#x2F;cobra" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;spf13&#x2F;cobra</a><p>Tho admittedly it works in reverse; it generates the doc&#x2F;help info rather than parsing it into an AST. It addresses the “boilerplate” issue with code gen as well, but it has a CLI to generate code that’s pretty powerful.<p>For instance, how does docli handle subcommands? How about global vs command specific flags? For any case beyond the basic single command CLI, it seems like there would need to be all sorts of magic and non-obvious formatting requirements on the doc string.
评论 #19511369 未加载
评论 #19447583 未加载
matt-attack大约 6 年前
Anyone have a recommendation for Node.js? I&#x27;ve been extremely frustrated with commander [1].<p>[1] <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;commander" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;commander</a>
评论 #19443042 未加载
评论 #19443776 未加载
评论 #19448080 未加载
评论 #19443096 未加载
calebwin大约 6 年前
I really like that graphic for the website and README! Did you make it?
评论 #19447443 未加载
maxaf大约 6 年前
Prior art: <a href="http:&#x2F;&#x2F;docopt.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;docopt.org&#x2F;</a>
评论 #19442681 未加载
评论 #19442705 未加载
CamouflagedKiwi大约 6 年前
Not really a fan of this approach. I don&#x27;t like the duality between the help text and the struct it gets bound to - much prefer the approach of generating the help text from a struct.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;jessevdk&#x2F;go-flags" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jessevdk&#x2F;go-flags</a> is my favourite option; it&#x27;s lightweight but amazingly featureful, and I much prefer the declarative approach to a programmatic one like the standard library flags package
pushpop大约 6 年前
Their example here confuse me:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;celicoo&#x2F;docli&#x2F;blob&#x2F;master&#x2F;examples&#x2F;terraform&#x2F;main.go" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;celicoo&#x2F;docli&#x2F;blob&#x2F;master&#x2F;examples&#x2F;terraf...</a><p>`workspace` isn&#x27;t a boolean flag. So it isn&#x27;t clear from that example how - or even if - docli can work with more complex conditional arguments.<p>Is someone with any familiarity with this project able to advise how you&#x27;d handle that in docli?
评论 #19445274 未加载
mongol大约 6 年前
For my purpose, go-flags was a great fit.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;jessevdk&#x2F;go-flags" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jessevdk&#x2F;go-flags</a>
henvic大约 6 年前
cobra is working pretty well for my needs: <a href="https:&#x2F;&#x2F;asciinema.org&#x2F;a&#x2F;192043" rel="nofollow">https:&#x2F;&#x2F;asciinema.org&#x2F;a&#x2F;192043</a><p>Nice to see a declarative approach, though. It certainly looks more natural. I&#x27;m certainly going to give it a try.
jlesk大约 6 年前
I really like the line art logo on the site, but it&#x27;s 2.4 MB (avatar.png).<p>Might want to size it down and run it through TinyPNG. :)
评论 #19447450 未加载
bfrydl大约 6 年前
It&#x27;s a little strange that I had to open the tutorial to find out what language this is for.
评论 #19442016 未加载
评论 #19447484 未加载
kvakvs大约 6 年前
Please put the language it is intended for somewhere as close to the page top as possible. The world isn&#x27;t all Go.