From a2aa173df494a6c19d8bf5d6044548606c989eb8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Apr 2024 10:23:48 -0400 Subject: [PATCH] When completion is unavailable, exit with non-zero status and emit message to stderr. Closes #671 --- keyring/completion.py | 5 +++-- newsfragments/671.bugfix.rst | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 newsfragments/671.bugfix.rst diff --git a/keyring/completion.py b/keyring/completion.py index 33fe36f..e49bc3d 100644 --- a/keyring/completion.py +++ b/keyring/completion.py @@ -1,4 +1,5 @@ import argparse +import sys try: import shtab @@ -10,8 +11,8 @@ class _MissingCompletionAction(argparse.Action): def __call__(self, parser, namespace, values, option_string): - print("Install keyring[completion] for completion support.") - parser.exit(0) + print("Install keyring[completion] for completion support.", file=sys.stderr) + parser.exit(1) def add_completion_notice(parser): diff --git a/newsfragments/671.bugfix.rst b/newsfragments/671.bugfix.rst new file mode 100644 index 0000000..1aa324b --- /dev/null +++ b/newsfragments/671.bugfix.rst @@ -0,0 +1 @@ +When completion is unavailable, exit with non-zero status and emit message to stderr. \ No newline at end of file