288: CLI now uses Command.group_args() to check for required arguments

This commit is contained in:
Jason Gerard DeRose
2008-09-10 23:33:36 +00:00
parent c17c5efb4e
commit 23e251a605
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -31,6 +31,10 @@ import plugable
import ipa_types
def exit_error(error):
sys.exit('ipa: ERROR: %s' % error)
def to_cli(name):
"""
Takes a Python identifier and transforms it into form suitable for the
@@ -195,6 +199,10 @@ class CLI(object):
def run_cmd(self, cmd, argv):
(args, kw) = self.parse(cmd, argv)
try:
args = cmd.group_args(*args)
except errors.ArgumentError, e:
exit_error('%s %s' % (to_cli(cmd.name), e.error))
self.run_interactive(cmd, args, kw)
def run_interactive(self, cmd, args, kw):
+1 -1
View File
@@ -225,9 +225,9 @@ class Command(plugable.Plugin):
'execute',
'__call__',
'smart_option_order',
'Option',
'args',
'options',
'group_args',
))
__Option = None
takes_options = tuple()