Return a value to the shell that called ipa

This commit is contained in:
Rob Crittenden
2008-10-22 17:52:32 -04:00
parent d44afa0f1a
commit f189b02996
2 changed files with 8 additions and 3 deletions

3
ipa
View File

@@ -25,9 +25,10 @@ Command Line Interface for IPA Administration.
The CLI functionality is implemented in ipalib/cli.py The CLI functionality is implemented in ipalib/cli.py
""" """
import sys
from ipalib import api from ipalib import api
from ipalib.cli import CLI from ipalib.cli import CLI
import ipalib.load_plugins import ipalib.load_plugins
cli = CLI(api) cli = CLI(api)
cli.run() sys.exit(cli.run())

View File

@@ -270,7 +270,7 @@ class CLI(object):
self.print_commands() self.print_commands()
print 'ipa: ERROR: unknown command %r' % key print 'ipa: ERROR: unknown command %r' % key
sys.exit(2) sys.exit(2)
self.run_cmd( return self.run_cmd(
self[key], self[key],
list(s.decode('utf-8') for s in args[1:]) list(s.decode('utf-8') for s in args[1:])
) )
@@ -280,7 +280,11 @@ class CLI(object):
try: try:
self.run_interactive(cmd, kw) self.run_interactive(cmd, kw)
except KeyboardInterrupt: except KeyboardInterrupt:
return return 0
except errors.RuleError, e:
print e
return 2
return 0
def run_interactive(self, cmd, kw): def run_interactive(self, cmd, kw):
for param in cmd.params(): for param in cmd.params():