diff --git a/kitty/cmds.py b/kitty/cmds.py index 83eb269d0..bdc9c9b2b 100644 --- a/kitty/cmds.py +++ b/kitty/cmds.py @@ -21,7 +21,7 @@ class MatchError(ValueError): ValueError.__init__(self, 'No matching {} for expression: {}'.format(target, expression)) -def cmd(short_desc, desc=None, options_spec=None, no_response=False, argspec='...'): +def cmd(short_desc, desc=None, options_spec=None, no_response=False, argspec='...', string_return_is_error=False): def w(func): func.short_desc = short_desc @@ -32,6 +32,7 @@ def cmd(short_desc, desc=None, options_spec=None, no_response=False, argspec='.. func.is_cmd = True func.impl = lambda: globals()[func.__name__[4:]] func.no_response = no_response + func.string_return_is_error = string_return_is_error return func return w @@ -299,7 +300,8 @@ reset the layout to its default configuration. type=bool-set If specified close the window this command is run in, rather than the active window. ''', - argspec='' + argspec='', + string_return_is_error=True ) def cmd_resize_window(global_opts, opts, args): return {'match': opts.match, 'increment': opts.increment, 'axis': opts.axis, 'self': opts.self} diff --git a/kitty/remote_control.py b/kitty/remote_control.py index e49df4f38..44f847b64 100644 --- a/kitty/remote_control.py +++ b/kitty/remote_control.py @@ -130,5 +130,8 @@ def main(args): if response.get('tb'): print(response['tb'], file=sys.stderr) raise SystemExit(response['error']) - if 'data' in response: - print(response['data']) + data = response.get('data') + if data is not None: + if func.string_return_is_error and isinstance(data, str): + raise SystemExit(data) + print(data) diff --git a/kitty/tabs.py b/kitty/tabs.py index 8937c0257..02ad19ccf 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -166,7 +166,7 @@ class Tab: # {{{ increment_as_percent = self.current_layout.bias_increment_for_cell(is_horizontal) * increment if self.current_layout.modify_size_of_window(self.windows, window_id, increment_as_percent, is_horizontal): self.relayout() - return '' + return return 'Could not resize' def reset_window_sizes(self):