From 634397cdaf5e465b33181418ce6efbfef1799124 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 10 May 2023 17:45:07 +0200 Subject: [PATCH] cli: fix `done` not returning The previous `Done` commands would not return properly. All `Done`/`Exit` commands have also gotten the common number 9 --- worblehat/cli/main.py | 2 +- worblehat/cli/prompt_utils.py | 13 +++++++------ worblehat/cli/subclis/bookcase_item.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/worblehat/cli/main.py b/worblehat/cli/main.py index 2ea1885..288bffd 100644 --- a/worblehat/cli/main.py +++ b/worblehat/cli/main.py @@ -289,7 +289,7 @@ class WorblehatCli(NumberedCmd): 'f': do_abort, 'doc': 'Abort changes', }, - 8: { + 9: { 'f': do_exit, 'doc': 'Exit', }, diff --git a/worblehat/cli/prompt_utils.py b/worblehat/cli/prompt_utils.py index a5eaf46..78f5a0a 100644 --- a/worblehat/cli/prompt_utils.py +++ b/worblehat/cli/prompt_utils.py @@ -147,17 +147,18 @@ class NumberedCmd(Cmd): except (ValueError, KeyError): return - self.funcs[i]['f'](self, arg) + return self.funcs[i]['f'](self, arg) def default(self, arg: str): - self._default(arg) + return self._default(arg) - def _postcmd(self, stop: bool, line: str) -> bool: - print() - print('-----------------') - print() + def _postcmd(self, stop: bool, _: str) -> bool: + if not stop: + print() + print('-----------------') + print() return stop diff --git a/worblehat/cli/subclis/bookcase_item.py b/worblehat/cli/subclis/bookcase_item.py index 485d305..7a3589e 100644 --- a/worblehat/cli/subclis/bookcase_item.py +++ b/worblehat/cli/subclis/bookcase_item.py @@ -74,7 +74,7 @@ class BookcaseItemCli(NumberedCmd): 'f': do_update_data, 'doc': 'Pull updated data from online databases', }, - 4: { + 9: { 'f': do_done, 'doc': 'Done', },