[IPython-user] Hierarchical TAB completion?
Pierre Bielmann
pierre.bielmann@gmail....
Tue Apr 3 07:46:55 CDT 2007
Hi all,
Is it possible to implement (with iPython) a shell which behaves like a
classical
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
string parameter
(user) # <TAB>
gives e.g.
name
password
shell
..
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'
or even
(user) #: set -n 'John Cool' -s '/bin/sh'
(user) #: set -n 'John Cool' shell='/bin/sh'
(user) #: show
e.g. all properties are shown
user: john
Name: John Cool
Password: ztztztztz
Shell: /bin/sh
...
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
syntax possibilities
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
--
Pierre Bielmann <pierre.bielmann@gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20070403/751ca0e3/attachment.html
More information about the IPython-user
mailing list