From 23e251a605c8e7cc44450411b841141cc0979638 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 10 Sep 2008 23:33:36 +0000 Subject: 288: CLI now uses Command.group_args() to check for required arguments --- ipalib/cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ipalib/cli.py') 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): -- cgit