diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 23:33:36 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 23:33:36 +0000 |
commit | 23e251a605c8e7cc44450411b841141cc0979638 (patch) | |
tree | 640e62ee7dd7c7a365294a875c959d95649e6e74 | |
parent | c17c5efb4e30c78bb53022e86f74b718dd49e758 (diff) | |
download | freeipa.git-23e251a605c8e7cc44450411b841141cc0979638.tar.gz freeipa.git-23e251a605c8e7cc44450411b841141cc0979638.tar.xz freeipa.git-23e251a605c8e7cc44450411b841141cc0979638.zip |
288: CLI now uses Command.group_args() to check for required arguments
-rw-r--r-- | ipalib/cli.py | 8 | ||||
-rw-r--r-- | ipalib/public.py | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 54693ffd..594e2812 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -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): diff --git a/ipalib/public.py b/ipalib/public.py index 84d321be..9f12a45b 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -225,9 +225,9 @@ class Command(plugable.Plugin): 'execute', '__call__', 'smart_option_order', - 'Option', 'args', 'options', + 'group_args', )) __Option = None takes_options = tuple() |