commit 8fb48354bcb063080abdb85c7323c5291e8de158
parent 9907c1e50ba225f29d2b0d4709e5d7749cbc9a22
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Sat, 2 Nov 2024 15:48:27 +0000
Incompatible show options are now reported as an error
Diffstat:
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/pashage.sh b/src/pashage.sh
@@ -1385,30 +1385,32 @@ cmd_insert() {
cmd_list_or_show() {
PARSE_ERROR=no
+ USE_CLIP=no
+ USE_QRCODE=no
while [ $# -ge 1 ]; do
case "$1" in
-c|--clip)
- SHOW=clip
+ USE_CLIP=yes
shift ;;
-c?*)
SELECTED_LINE="${1#-c}"
- SHOW=clip
+ USE_CLIP=yes
shift ;;
--clip=*)
SELECTED_LINE="${1#--clip=}"
- SHOW=clip
+ USE_CLIP=yes
shift ;;
-q|--qrcode)
- SHOW=qrcode
+ USE_QRCODE=yes
shift ;;
-q?*)
SELECTED_LINE="${1#-q}"
- SHOW=qrcode
+ USE_QRCODE=yes
shift ;;
--qrcode=*)
SELECTED_LINE="${1#--qrcode=}"
- SHOW=qrcode
+ USE_QRCODE=yes
shift ;;
--)
shift
@@ -1421,6 +1423,21 @@ cmd_list_or_show() {
esac
done
+ case "${USE_CLIP}-${USE_QRCODE}" in
+ no-no)
+ SHOW=text
+ ;;
+ yes-no)
+ SHOW=clip
+ ;;
+ no-yes)
+ SHOW=qrcode
+ ;;
+ *)
+ PARSE_ERROR=yes
+ ;;
+ esac
+
if [ "${PARSE_ERROR}" = yes ]; then
if [ "${COMMAND}" = "l${COMMAND#l}" ]; then
cmd_usage 'Usage: ' list >&2