diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-12 02:03:47 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-12 02:03:47 +0000 |
commit | bc4b26ffca7b48db70006c99ddb6084542b1df88 (patch) | |
tree | cdecf8c5cf55eb29111e227a2e6f724f072d80fd /ipalib/cli.py | |
parent | 902614a76297f6c3e3d329df6a6a5010765a37f5 (diff) | |
download | freeipa-bc4b26ffca7b48db70006c99ddb6084542b1df88.tar.gz freeipa-bc4b26ffca7b48db70006c99ddb6084542b1df88.tar.xz freeipa-bc4b26ffca7b48db70006c99ddb6084542b1df88.zip |
114: Fixed cmd.__get_options(); more work on CLI
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r-- | ipalib/cli.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index e0ba11f8..40edc890 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -21,8 +21,9 @@ Functionality for Command Line Inteface. """ -import sys import re +import sys +import optparse def to_cli(name): @@ -43,6 +44,10 @@ def from_cli(cli_name): return cli_name.replace('-', '_') +def _(arg): + return arg + + class CLI(object): def __init__(self, api): self.__api = api @@ -74,4 +79,14 @@ class CLI(object): self.run_cmd(cmd) def run_cmd(self, cmd): - print self[cmd] + (options, args) = self.build_parser(cmd) + print options + + def build_parser(self, cmd): + parser = optparse.OptionParser() + for option in self[cmd].options: + parser.add_option('--%s' % to_cli(option.name), + help=option.get_doc(_), + ) + + (options, args) parser.parse_args() |