4 ms·
Good idea. I wonder if anyone has done this for general unix command-line apps by parsing out the man pages on the fly. It probably wouldn't work for all progra
by jayvanguard 12y ago
Good idea. I wonder if anyone has done this for general unix command-line apps by parsing out the man pages on the fly. It probably wouldn't work for all programs but may be gnu style ones would be consistent enough.
- eldelshell 12y agoI too was expecting something like what you describe but by parsing -h --help output.
- gioele 12y agoThe bash-completion script can deduce which options are supported by an application by parsing the output of --help and of usage lines. In Bash. http://anonscm.debian.org/cgit/bash-completion/bash-completion.git/tree/bash_completion#n771 http://anonscm.debian.org/cgit/bash-completion/bash-completi...
- DennisP 12y agoEither way, it might be neat to do it dynamically, so command-line programs could be turned into guis live by typing "guify xyz". The gui could have labels with the command options, and upon hitting enter they could close and send the command back to the command line, so you're learning the commands as you go.
- naranja 12y agoThe fish shell does this with an explicit command (fish_update_completions) and offers an awesome Tab completion in the current Github version
- jlarocco 12y agoI've done something similar to this a few times, both in Python. Once to create a TkInter GUI for an internal command line app, and once to wrap sg3_utils for use in Python scripts. In general, I think it could "mostly work" a good portion of the time, but it'd be pretty difficult to get working 100% of the time without a lot of tweaking to the parser.
- agumonkey 12y agoNot far from that there's docopt who parses POSIX compliant arguments descriptions.
- michaelmior 12y agoIs there such a thing as POSIX-compliant argument descriptions? I know POSIX specifies some things about the format of options, but I didn't realize there was a formalized option description language.
- euid 12y agoYes. IEEE Std. 1003.1 Utility Conventions http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_... This is actually how Docopt happened (Vladimir Keleshev mentioned it in the PyCon UK 2012 talk).
- michaelmior 12y agoCool! Thanks for the reference :)
- agumonkey 12y agoMe neither, I thought docopt was a hardcoded fragile thing, until the author explains everything is almost perfectly defined.
- davvid 12y agoThe Python "argcomplete" module[1] generates shell completions for any program that uses argparse, so it's certainly doable. [1] https://github.com/kislyuk/argcomplete https://github.com/kislyuk/argcomplete
- vdm 12y ago> parsing out the man pages https://github.com/idank/explainshell https://github.com/idank/explainshell