diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-27 00:25:33 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-27 00:25:33 +0000 |
commit | 330c17730c056428c70bd4612799cac44306f513 (patch) | |
tree | 2a9fa0724472f08ffb03b8eb085842ada938a549 | |
parent | 74a3cf8d2860665cc37a8f2787f950246c0ba10e (diff) | |
download | freeipa.git-330c17730c056428c70bd4612799cac44306f513.tar.gz freeipa.git-330c17730c056428c70bd4612799cac44306f513.tar.xz freeipa.git-330c17730c056428c70bd4612799cac44306f513.zip |
201: Added new cli command 'console' that starts a custom interactive Python console
-rw-r--r-- | ipalib/cli.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 1ad53058..989c24f6 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -23,6 +23,7 @@ Functionality for Command Line Inteface. import re import sys +import code import public @@ -44,7 +45,7 @@ def from_cli(cli_name): class help(public.Command): - 'display help on command' + 'Display help on command' def __call__(self, key): if from_cli(key) not in self.api.Command: print 'help: no such command %r' % key @@ -52,6 +53,16 @@ class help(public.Command): print 'Help on command %r:' % key +class console(public.Command): + 'Start IPA Interactive Python Console' + + def __call__(self): + code.interact( + '(Custom IPA Interactive Python Console)', + local=dict(api=self.api) + ) + + class CLI(object): __d = None __mcl = None @@ -82,6 +93,7 @@ class CLI(object): def finalize(self): api = self.api api.register(help) + api.register(console) api.finalize() def d_iter(): for cmd in api.Command(): |