mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
114: Fixed cmd.__get_options(); more work on CLI
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user