* --help trough _use_lo , but how with -h style? @ 2000-06-28 13:02 Matthias Kopfermann 2000-06-28 13:12 ` Sven Wischnowsky 2000-06-28 13:22 ` Andrej Borsenkow 0 siblings, 2 replies; 4+ messages in thread From: Matthias Kopfermann @ 2000-06-28 13:02 UTC (permalink / raw) To: Zsh Users Hi again, After I got the information about the use of `compdef _use_lo x y z' to have x y and z commands completed I asked myself: How can i do it with these `-h' commands. e.g. mutt only wants -x flags. i would like to have such commands being completed just like the much nicer to read --x commands. is there a function already for these kind of commands? (I am not talking about a specific mutt completion though that may be nice, too.) BTW: i used to use perl for having --help commands being completed and i have a function that does it with -h commands , too, but it would be much nicer, if there was such a function in plain-zsh already. Thats why i ask. -- And in the end the love you take is equal to the love you make THE BEATLES ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: --help trough _use_lo , but how with -h style? @ 2000-06-28 13:12 ` Sven Wischnowsky 0 siblings, 0 replies; 4+ messages in thread From: Sven Wischnowsky @ 2000-06-28 13:12 UTC (permalink / raw) To: zsh-users Matthias Kopfermann wrote: > Hi again, > After I got the information about the use of `compdef _use_lo x y z' to > have x y and z commands completed I asked myself: > How can i do it with these `-h' commands. e.g. mutt only wants > -x flags. i would like to have such commands being completed just > like the much nicer to read --x commands. is there a function > already for these kind of commands? (I am not talking about a > specific mutt completion though that may be nice, too.) > > BTW: i used to use perl for having --help commands being > completed and i have a function that does it with -h commands , > too, but it would be much nicer, if there was such a function in > plain-zsh already. Thats why i ask. No, we don't have that yet. But we have a completion function for mutt. Hm, if you have a function to generate the option names you can easily use that. I guess the function puts the options into the $reply array (I'll assume the strings generated include the `-'), so you can do: _use_so() { # ;-) if [[ $PREFIX = -* ]]; then ... # call perl-function-thingy compadd -a reply else _default fi } To make this nicer, change the `compadd'-line to: local expl _wanted options expl option compadd -a reply Bye Sven -- Sven Wischnowsky wischnow@informatik.hu-berlin.de ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: --help trough _use_lo , but how with -h style? 2000-06-28 13:02 --help trough _use_lo , but how with -h style? Matthias Kopfermann 2000-06-28 13:12 ` Sven Wischnowsky @ 2000-06-28 13:22 ` Andrej Borsenkow 2000-06-28 15:56 ` Bart Schaefer 1 sibling, 1 reply; 4+ messages in thread From: Andrej Borsenkow @ 2000-06-28 13:22 UTC (permalink / raw) To: Matthias Kopfermann, Zsh Users I am not sure what do you mean. _use_lo simply does very general parsing of 'command --help' output. But note, that --help is de facto standard for GNU long options; and help format is more or less (actually, much less :-) similar between commands. What you want is a function that would parse general output of arbitrary command and generate useful completion out of this. I doubt that it ever be possible. Please, note, that as far as I can tell --help parsing is used only in three completion functions currently - _configure, _tar and _gdb. Of these three I believe that _tar and _gdb use it only for historical reasons - the single command where this makes sense is _configure. Note, that parsing of help text has many drawbacks. You cannot supply description; you cannot define mutualy excluding options; you cannot define mutually dependent options or option sets. I.e. _arguments is much better suited - with the additional cost of writing separate function for every command. Are you aware about _arguments and it's possibilities? -andrej > -----Original Message----- > From: Matthias Kopfermann [mailto:kopfermann@trio-hittfeld.de] > Sent: Wednesday, June 28, 2000 5:03 PM > To: Zsh Users > Subject: --help trough _use_lo , but how with -h style? > > > Hi again, > After I got the information about the use of `compdef _use_lo > x y z' to > have x y and z commands completed I asked myself: > How can i do it with these `-h' commands. e.g. mutt only wants > -x flags. i would like to have such commands being completed just > like the much nicer to read --x commands. is there a function > already for these kind of commands? (I am not talking about a > specific mutt completion though that may be nice, too.) > > BTW: i used to use perl for having --help commands being > completed and i have a function that does it with -h commands , > too, but it would be much nicer, if there was such a function in > plain-zsh already. Thats why i ask. > > -- > And in the end the love you take > is equal to the love you make > THE BEATLES > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: --help trough _use_lo , but how with -h style? 2000-06-28 13:22 ` Andrej Borsenkow @ 2000-06-28 15:56 ` Bart Schaefer 0 siblings, 0 replies; 4+ messages in thread From: Bart Schaefer @ 2000-06-28 15:56 UTC (permalink / raw) To: Zsh Users On Jun 28, 3:02pm, Matthias Kopfermann wrote: } Subject: --help trough _use_lo , but how with -h style? } } Hi again, } After I got the information about the use of `compdef _use_lo x y z' to } have x y and z commands completed I asked myself: } How can i do it with these `-h' commands. e.g. mutt only wants } -x flags. If I understand you correctly, you mean that there are at least several commands that you use that generate help output when given `-h', and you would like the completion system to treat `command -<TAB>' as a reason to execute `command -h' and then parse the resulting output. The first thing you should do (which perhaps you have) is make sure that there aren't already completion functions for those commands. After you have run `compinit', you can see which commands already have completions this way: print -l ${(ok)_comps} | less (substitute your favorite pager). The first several lines will look like `-something-' where `something' is the name of one of the special contexts that the completion system understands; the rest are command names. } [...] i have a function that does it with -h commands , } too, but it would be much nicer, if there was such a function in } plain-zsh already. Thats why i ask. If the -h output is really as consistently formatted as GNU --help (which isn't very, I guess) then send your function off to zsh-workers and it'll probably get included in the next release. On Jun 28, 3:12pm, Sven Wischnowsky wrote: } Subject: Re: --help trough _use_lo , but how with -h style? } } Hm, if you have a function to generate the option names you can easily } use that. I guess the function puts the options into the $reply array } (I'll assume the strings generated include the `-'), so you can do: } } _use_so() { # ;-) } if [[ $PREFIX = -* ]]; then } ... # call perl-function-thingy } compadd -a reply } else } _default } fi } } } } To make this nicer, change the `compadd'-line to: } } local expl } _wanted options expl option compadd -a reply And to make it even nicer, _use_so should respect the `command' style for the `options' tag and employ _call to invoke the function-thingy, which is why I suggest that he send us the function to play with. On Jun 28, 5:22pm, Andrej Borsenkow wrote: } Subject: RE: --help trough _use_lo , but how with -h style? } } [...] What you want is a function that } would parse general output of arbitrary command and generate useful } completion out of this. I doubt that it ever be possible. I don't think he's asking for quite that much. } Please, note, that as far as I can tell --help parsing is used only in } three completion functions currently - _configure, _tar and _gdb. Of } these three I believe that _tar and _gdb use it only for historical } reasons - the single command where this makes sense is _configure. Hmm, you're right, I missed that _arguments has to be given both an option of `--' as well as a string-to-be-completed of `--' before it will invoke `command --help'. That would make _use_so useful even for GNU commands that have no other default completion, assuming you could set the command style so as to choose whether to pass -h or --help. } Note, that parsing of help text has many drawbacks. You cannot supply } description; Not strictly true; if you really could parse the help text, the parser could add the help text itself as the descriptions. I'm skeptical that this is possible in general, but it might be possible for some specific commands. } you cannot define mutualy excluding options; you cannot } define mutually dependent options or option sets. I.e. _arguments is } much better suited - with the additional cost of writing separate } function for every command. Which is exactly what he wants to avoid, I suspect. We haven't yet achieved the goal that writing a completion function is not daunting to the average user. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2000-06-28 15:57 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2000-06-28 13:02 --help trough _use_lo , but how with -h style? Matthias Kopfermann 2000-06-28 13:12 ` Sven Wischnowsky 2000-06-28 13:22 ` Andrej Borsenkow 2000-06-28 15:56 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).