summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/cli.py15
-rw-r--r--ipalib/errors.py2
2 files changed, 13 insertions, 4 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index df0cd37c..1a1673e4 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -36,7 +36,7 @@ import frontend
import backend
import plugable
import util
-from errors import PublicError, CommandError, HelpError, InternalError, NoSuchNamespaceError, ValidationError
+from errors import PublicError, CommandError, HelpError, InternalError, NoSuchNamespaceError, ValidationError, NotFound
from constants import CLI_TAB
from parameters import Password, Bytes
from request import ugettext as _
@@ -440,6 +440,9 @@ class textui(backend.Backend):
return -1
counter = len(entries)
+ if counter == 0:
+ raise NotFound(reason="No matching entries found")
+
i = 1
for e in entries:
# There is no guarantee that all attrs are in any given
@@ -690,7 +693,11 @@ class cli(backend.Executioner):
if param.password and param.name in kw:
del kw[param.name]
(args, options) = cmd.params_2_args_options(**kw)
- cmd.output_for_cli(self.api.Backend.textui, result, *args, **options)
+ rv = cmd.output_for_cli(self.api.Backend.textui, result, *args, **options)
+ if rv:
+ return rv
+ else:
+ return 0
finally:
self.destroy_context()
@@ -799,7 +806,7 @@ def run(api):
api.register(klass)
api.load_plugins()
api.finalize()
- api.Backend.cli.run(argv)
+ sys.exit(api.Backend.cli.run(argv))
except KeyboardInterrupt:
print ''
api.log.info('operation aborted')
@@ -811,4 +818,4 @@ def run(api):
if error is not None:
assert isinstance(error, PublicError)
api.log.error(error.strerror)
- sys.exit(error.errno)
+ sys.exit(error.rval)
diff --git a/ipalib/errors.py b/ipalib/errors.py
index a08ee959..82905b39 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -240,6 +240,7 @@ class PublicError(StandardError):
"""
errno = 900
+ rval = 1
format = None
def __init__(self, format=None, message=None, **kw):
@@ -748,6 +749,7 @@ class NotFound(ExecutionError):
"""
errno = 4001
+ rval = 2
format = _('%(reason)s')
class DuplicateEntry(ExecutionError):