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