diff --git a/changelog.rst b/changelog.rst index c1f1b8a2d..de78e2f5c 100644 --- a/changelog.rst +++ b/changelog.rst @@ -7,6 +7,7 @@ Features: * Add cursor shape support for vi mode. When ``vi = True``, the terminal cursor now reflects the current editing mode: beam in INSERT, block in NORMAL, underline in REPLACE. Uses prompt_toolkit's ``ModalCursorShapeConfig``. +* Add the option to force-quit pgcli when a transaction is in progress. * Add support of Python 3.14. * Drop support of Python 3.9. diff --git a/pgcli/main.py b/pgcli/main.py index 51d21b323..fe889dee6 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -933,7 +933,7 @@ def _check_ongoing_transaction_and_allow_quitting(self): while 1: try: choice = click.prompt( - "A transaction is ongoing. Choose `c` to COMMIT, `r` to ROLLBACK, `a` to abort exit.", + "A transaction is ongoing. Choose `c` to COMMIT, `r` to ROLLBACK, `a` to abort exit, `force` to exit anyway.", default="a", ) except click.Abort: @@ -945,6 +945,8 @@ def _check_ongoing_transaction_and_allow_quitting(self): choice = choice.lower() if choice == "a": return False # do not quit + if choice == "force": + return True # quit anyway if choice == "c": query = self.execute_command("commit") return query.successful # quit only if query is successful