summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-10-22 17:52:32 -0400
committerRob Crittenden <rcritten@redhat.com>2008-10-22 17:52:32 -0400
commitf189b02996668e5d600f1abed675cb20cd72290f (patch)
tree3d28f8a192e6de150482277bdf61cfeeac618d61
parentd44afa0f1a19d5e71c5578eedefda2dccd6dc083 (diff)
downloadfreeipa-f189b02996668e5d600f1abed675cb20cd72290f.tar.gz
freeipa-f189b02996668e5d600f1abed675cb20cd72290f.tar.xz
freeipa-f189b02996668e5d600f1abed675cb20cd72290f.zip
Return a value to the shell that called ipa
-rwxr-xr-xipa3
-rw-r--r--ipalib/cli.py8
2 files changed, 8 insertions, 3 deletions
diff --git a/ipa b/ipa
index 31848f7b3..5122af0a3 100755
--- a/ipa
+++ b/ipa
@@ -25,9 +25,10 @@ Command Line Interface for IPA Administration.
The CLI functionality is implemented in ipalib/cli.py
"""
+import sys
from ipalib import api
from ipalib.cli import CLI
import ipalib.load_plugins
cli = CLI(api)
-cli.run()
+sys.exit(cli.run())
diff --git a/ipalib/cli.py b/ipalib/cli.py
index ab7e36204..4e5e433ed 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -270,7 +270,7 @@ class CLI(object):
self.print_commands()
print 'ipa: ERROR: unknown command %r' % key
sys.exit(2)
- self.run_cmd(
+ return self.run_cmd(
self[key],
list(s.decode('utf-8') for s in args[1:])
)
@@ -280,7 +280,11 @@ class CLI(object):
try:
self.run_interactive(cmd, kw)
except KeyboardInterrupt:
- return
+ return 0
+ except errors.RuleError, e:
+ print e
+ return 2
+ return 0
def run_interactive(self, cmd, kw):
for param in cmd.params():