4 ms·
Cobra (https://github.com/spf13/cobra https://github.com/spf13/cobra), which is a pretty popular library for Go CLI applications, behaves more like classical GN
by hnjst 6y ago
Cobra (https://github.com/spf13/cobra https://github.com/spf13/cobra), which is a pretty popular library for Go CLI applications, behaves more like classical GNU tools. It also offers usage/help autogeneration and autocompletion for popular shells.
Not sure about the relevant point on compact short options syntax as in `tar -xvzf archive.tgz` though...
(edit) after a quick & sloppy test it seems to work as expected
- ben0x539 6y agoYeah but `tar xvzf archive.tgz` also works so I remain wary of tar. Basically every time I have tried to do something that's not tfz or cfz or xfz, it went wrong until I checked the manpage.
- hnjst 6y agoRight. I probably picked one of the most flaky examples, sorry for that. Let's say `ls -lah` that (I hope...) is less ambiguous. In my defense, the specific example I gave is valid for both GNU and BSD versions of tar. If I understood correctly, the issue you point to (order among short form flags) is related to the fact that `f` expects an argument and consequently has to appear in the last position.
- ben0x539 6y agoAh, it's not a direct argument when you omit the hyphen and fall into "traditional" mode. I think after years and years I can finally wrap my head around how that works. :D
- chrisweekly 6y agospeaking of `man`, why can't it be more like `tldr`?
- hnjst 6y agoI guess you could consider https://github.com/tldr-pages/tldr https://github.com/tldr-pages/tldr. I personally wouldn't touch that, but that's related to my allergies to JS ecosystem and predisposition to panic attacks when I see stuff like that https://github.com/tldr-pages/tldr/blob/master/package-lock.json https://github.com/tldr-pages/tldr/blob/master/package-lock.....
- samatman 6y agoI've switched to tealdeer: same database, rust implementation. https://github.com/dbrgn/tealdeer https://github.com/dbrgn/tealdeer
- hnjst 6y agoI'm generally satisfied by ZSH inline options summary, but I'm happy to see a sane instantiation of this, it clearly fits a need. Thanks for the pointer (and sorry for the troll :/).
- chrisweekly 6y ago"ZSH inline options summary"? TIA if you could explain; is it native zsh or a plugin?
- Geezus_42 6y agoThere's also tealdeer in rust.
- pwdisswordfish8 6y agoBecause learning from unexplained examples is useless.
- coldtea 6y agoIs it? That's how humans learn to speak their language, one of the most complex tasks they need to achieve in their life...
- mauvehaus 6y agoOn the other hand, cocking up an unfamiliar phrase in a spoken language doesn't usually result in accidentally killing the listener. I haven't yet had a computer ask for clarification when I used tar or dd in an uncommon and destructive way.
- coldtea 6y agoYou don't "have to" use the examples, you can read them as get a feel, and read the captions to find the one that does what you want... Which is faster and probably safer than scanning the documentation for individual flags and hopping you got the nuances right... See, the two cases aren't: (1) Thoroughly study man page -> (2) Become expert at the command's options (3) try command secure in your mastery of it vs (2) Check tldr examples -> (2) try command They're rather: (1) Open man page, (2) scan and skim the man page and the dozens of irrelevant flags, caveats, and obscure options, until you find some flags that look to do what you want, (3) half-read them, (4) try command vs (2) Check tldr examples, (2) find an example that does what you want (which is usually one of the covered use cases) (3) try the command using the example syntax