Line completion with custom commands
Steve Holden
steve at holdenweb.com
Fri Jan 9 06:03:47 EST 2009
gu wrote:
>
> Hi, my Python program can be launched with a range of different options
> (or subcommands) like:
>
> $ myProgram doSomething
> $ myProgram doSomethingElse
> $ myProgram nowDoSomethingDifferent
>
> I want it to use auto-completion with so that if i type "myProgram d" it
> returns "myProgram doSomething" and if i type "myProgram n" it renders
> "myProgram nowDoSomethingDifferent". This is similar to the average use
> of the module rlcompleter, but it does not pick possible completion
> options from the filesystem (or from history) but from a custom set of
> strings (that correspond to the available options for my program)
>
> Any idea on how to implement this?
>
> I'm aware of the variable PYTHONSTARTUP (that should point to a file I
> don't know how to write).
>
> As a working example, django-admin (from the django package) has the
> same exact feature i'm looking for
The issue here is that Python doesn't get control until afer you've hit
RETURN on the command line. so nothing you can do in your program or
interpreter setup will have any effect on how the command shell behaves.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list