Re: shell completion support for optparse/optik

Greg Ward <[email protected]> Tue, 16 Sep 2003 21:37:24 -0400
Newsgroups gmane.comp.python.optik.user
Message-ID <[email protected]>
On 16 September 2003, Martin Blais said:
> i've just had an idea, not sure if it's already been discussed for
> your optik package, just wondering what you think:
> 
> i was thinking that given that the parser has a pretty complete
> description of the input parameters, it would probably be possible to
> write a single bash function for all optparse-using programs, to
> perform completion by invoking the program with a particular option,
> something like "--perform-complete"; the option parser, given it has
> seen that option, instead of returning, would return the completion
> string to the shell.

Cute idea!  And AFAIK you're the first to come up with it.

> also, to deal with the arguments, we could give it some object/method to deal 
> with completion for the arguments, say something like this::
> 
>       parser = optparse.OptionParser(\
>                   complete=optparse.GlobCompletion(['*.tar.gz', '*.tar.bz2'])  
I don't understand what the point of tihs is.

> any thoughts?  do you think this is implementable?

Dunno -- I don't know how programmable shell completion works.  Feel
free to submit a patch, but keep it short and simple.  And don't make it
specific to bash -- some of use zsh.  ;-)  (And being able to query an
OptionParser about what options it supports might be useful in other
contexts.)

        Greg
-- 
Greg Ward <[email protected]>                         http://www.gerg.ca/
This email message may have come into contact with peanuts.


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf