diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-11 19:35:57 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-11 19:35:57 +0000 |
commit | 92824182911007ce3e9cf4f858f70434594ee5dd (patch) | |
tree | 511111922021c30297cd3aa3f88144c5e7161e8d /ipalib/cli.py | |
parent | 5313e5a491ceefe866a287cb4c320f0fee0474e2 (diff) | |
download | freeipa.git-92824182911007ce3e9cf4f858f70434594ee5dd.tar.gz freeipa.git-92824182911007ce3e9cf4f858f70434594ee5dd.tar.xz freeipa.git-92824182911007ce3e9cf4f858f70434594ee5dd.zip |
110: Started fleshing out more in cli.py
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r-- | ipalib/cli.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 5e257f70..63988337 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -21,6 +21,8 @@ Functionality for Command Line Inteface. """ +import sys +import re def to_cli(name): """ @@ -38,3 +40,32 @@ def from_cli(cli_name): """ assert isinstance(cli_name, basestring) return cli_name.replace('-', '_') + + +class CLI(object): + def __init__(self, api): + self.__api = api + + def __get_api(self): + return self.__api + api = property(__get_api) + + def print_commands(self): + for cmd in self.api.cmd: + print to_cli(cmd.name) + + def run(self): + if len(sys.argv) < 2: + self.print_commands() + print 'Usage: ipa COMMAND [OPTIONS]' + sys.exit(2) + return + name= sys.argv[1] + if name == '_api_': + print_api() + sys.exit() + elif name not in api.cmd: + print_commands() + print 'ipa: ERROR: unknown command %r' % name + sys.exit(2) + api.cmd[name]() |