[IPython-user] Hierarchical TAB completion?
Tue Apr 3 07:46:55 CDT 2007
Is it possible to implement (with iPython) a shell which behaves like a
Router Command Line Shell (e.g. Cisco IOS shell, etc.)? I'd like to "enter"
objects in a hierachical
fashion and execute commands/methods and also have command line completion
only in that context
(and not globally). Here is a simple example of what I have in mind:
# user john
(user) # name 'John Cool'
The class "user" ("john" is an instance of it) has a method "name" with one
(user) # <TAB>
So TAB completion should only give
* the method names in this context
* other global commands like 'show' which can have a special implementation
in that context
* interesting systems commands (which could be used in a special way in that
context, e.g. is
the user logged in, his disk quota, etc.)
It would also be nice to set poperties like
(user) #: name='John Cool'
(user) #: set name='John Cool' shell='/bin/sh'
(user) #: set -n 'John Cool' -s '/bin/sh'
(user) #: set -n 'John Cool' shell='/bin/sh'
(user) #: show
e.g. all properties are shown
Name: John Cool
Ok let's finish this simple example here:
(user) # commit
(this could be a real transaction which can be rolled back!)
# show user john
So what I try to find out is if I could implement a shell with iPython which
allows me to
do object traversal (with correpsonding command completion) and has the same
like a classical shell (Bash, etc.).
The shell commands i.e. classes (like "user") should be known to the shell
(implemented as plugins) and
register their syntax globally (could be done even during a running
session), but should only be loaded
when I enter a corresponsing object (# user john).
If it possible to realize that with custom completers this is fine, I just
do not know how? Being able to
enter Python objects in a generic fashion would would be cool though!
Any help or comments welcome (maybe I overlooked somehting?)
Pierre Bielmann <email@example.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-user