TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

131 pointsby celicooabout 6 years ago

15 comments

sametmaxabout 6 years ago
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 未加载
hwjabout 6 years ago
This is a Go library that parses a usage string into an AST.
评论 #19442588 未加载
评论 #19447425 未加载
评论 #19442458 未加载
ilovecachingabout 6 years ago
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 未加载
deforciantabout 6 years ago
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_demabout 6 years ago
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-attackabout 6 years ago
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 未加载
calebwinabout 6 years ago
I really like that graphic for the website and README! Did you make it?
评论 #19447443 未加载
maxafabout 6 years ago
Prior art: <a href="http:&#x2F;&#x2F;docopt.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;docopt.org&#x2F;</a>
评论 #19442681 未加载
评论 #19442705 未加载
CamouflagedKiwiabout 6 years ago
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
pushpopabout 6 years ago
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 未加载
mongolabout 6 years ago
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>
henvicabout 6 years ago
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.
jleskabout 6 years ago
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 未加载
bfrydlabout 6 years ago
It&#x27;s a little strange that I had to open the tutorial to find out what language this is for.
评论 #19442016 未加载
评论 #19447484 未加载
kvakvsabout 6 years ago
Please put the language it is intended for somewhere as close to the page top as possible. The world isn&#x27;t all Go.