On 8/27/06, Martin Bähr <[EMAIL PROTECTED]> wrote: > hi, > > wouldn't it be nice if there was a way to have a progam automaticly > configure their own completions?
In a word: yes. ;-) > > i just thought about a way how this could be done: > > many programs use getopt to specify their options. > (at least i hope many do :-) A decent number do, yes. > > now, what about extending getopt so that it can export the configured > options in a way that completion aware shell can pick them up? > > any program that uses getopt would then automaticly get this capability, > allowing fish, bash, zsh and all the others to get uptodate completions > without needing to manually keep them in sync. > > all that is needed is an api that works for all the shells out there > (and i am almost guessing that fish has the most elaborate completion > system so that this should already be a superset of what others might > need) and some code that takes the information which getopt already has, > and exports it through a specific option (like --export-completions) > > this might also be useful for other systems who want to display help > about programs in a consistent manner (instead of just running 'program > --help') Problems with this approach: Get this accepted in all getopt implementations. You don't get the description for of what any completions do, nor do you know what kind of parameters a switch accepts. So it's a very good start, far better than nothing, but not everything you need. In order to add the missing pieces, what you'd want to do is probably to use the output of 'COMMAND --export-completions' as the base of a regular completions script, where you can fill in the blanks yourself. The other way that has also been suggested to solve this is by parsing the man files of commands and converting them to completions. The first sentence of the description of a switch should actually often be a pretty decent baseline for the description of a switch, so this will give you a bit more to work with. There is a project called doclifter that reportedly does a very decent job of parsing man-pages and guessing what is what in them. I may sooner or later try one of these, but I'm still hoping soeone else will do so before. > > greetings, martin. > -- > cooperative communication with sTeam - caudium, pike, roxen and unix > offering: programming, training and administration - anywhere in the world > -- > pike programmer travelling and working in europe open-steam.org > unix system- bahai.or.at iaeste.(tuwien.ac|or).at > administrator (caudium|gotpike).org is.schon.org > Martin Bähr http://www.iaeste.or.at/~mbaehr/ -- Axel ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
