grimshot: Show usage when on invalid command

Show the usage output when an invalid command is received. Otherwise
things like `grimshot --help` save a screenshot, which is really
unexpected and hurts users trying to remember the right commands /
arguments.
This commit is contained in:
Hugo Osvaldo Barrera 2020-05-01 11:08:28 +02:00 committed by Drew DeVault
parent 61d59180b8
commit 25a0130e81

View file

@ -30,11 +30,23 @@ ACTION=${1:-usage}
SUBJECT=${2:-screen} SUBJECT=${2:-screen}
FILE=${3:-$(getTargetDirectory)/$(date -Ins).png} FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}
if [ "$ACTION" = "usage" ] ; then if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
echo "Usage:" echo "Usage:"
echo " grimshot copy|save win|screen|output|area [FILE]" echo " grimshot (copy|save) [win|screen|output|area] [FILE]"
echo "Troubleshoot:"
echo " grimshot check" echo " grimshot check"
echo " grimshot usage"
echo ""
echo "Commands:"
echo " copy: Copy the screenshot data into the clipboard."
echo " save: Save the screenshot to a regular file."
echo " check: Verify if required tools are installed and exit."
echo " usage: Show this message and exit."
echo ""
echo "Targets:"
echo " win: Currently active window."
echo " screen: All visible outputs."
echo " output: Currently active output."
echo " region: Manually select a region."
exit exit
fi fi