
Hi
How would it work on Unix? I assume that the command-line program just takes it's input "from the command line", so it doesn't get invoked until after you've finished typing the command...
Not necessarily true if completion is involved ... see below.
However, I know that zsh can do funky things like autocompleting ssh paths etc - and I think I remember seeing that there was some way a program could tell zsh what it could autocomplete to - but that is a hazy memory from a while ago.
Have a look at the (unreleased) bash completion for ghc-pkg: http://www.haskell.org/~kolmodin/code/ghc-bash-completion/ghc-pkg source it in bash to get it started. As you can see that ghc-pkg doesn't have special support for autocompletion, but it's possible anyway. To make it a bit simpler to write the completion, it's nice if the application in question has support for it. A nice example of this is darcs[1] which implements the command '--commands' and the flag '--list-option'. Cheers, Lennart Kolmodin [1] http://www.abridgegame.org/repos/darcs-unstable/darcs_completion