Fix 2nd argument not valid due to image path

This commit is contained in:
VirtuBox 2019-07-19 10:37:30 +02:00
parent 5d9d604436
commit c80ebccbd2
No known key found for this signature in database
GPG Key ID: 22EB296C97BAD476
2 changed files with 14 additions and 28 deletions

View File

@ -2,7 +2,7 @@
![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png) ![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png)
![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg) [![Travis (.org)](https://img.shields.io/travis/VirtuBox/img-optimize.svg)](https://travis-ci.org/VirtuBox/img-optimize) ![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg)
## Prerequisite ## Prerequisite

View File

@ -23,20 +23,21 @@ _help() {
echo "Usage: img-optimize [options] <images path>" echo "Usage: img-optimize [options] <images path>"
echo "If images path isn't defined, img-optimize will use the current directory " echo "If images path isn't defined, img-optimize will use the current directory "
echo " Options:" echo " Options:"
echo " --jpg <images path> ..... optimize all jpg images" echo " --jpg ..... optimize all jpg images"
echo " --png <images path> ..... optimize all png images" echo " --png ..... optimize all png images"
echo " --webp <images path> ..... convert all images in webp" echo " --webp ..... convert all images in webp"
echo " --nowebp <images path> ..... optimize all png & jpg images" echo " --nowebp ..... optimize all png & jpg images"
echo " --all <images path> ..... optimize all images (png + jpg + webp)" echo " --all ..... optimize all images (png + jpg + webp)"
echo " -i, --interactive ..... run img-optimize in interactive mode" echo " -i, --interactive ..... run img-optimize in interactive mode"
echo " -q, --quiet ..... run image optimization quietly" echo " -q, --quiet ..... run image optimization quietly"
echo " --path <images path> ..... define images path"
echo " Other options :" echo " Other options :"
echo " -h, --help, help ... displays this help information" echo " -h, --help, help ... displays this help information"
echo " --cmin [+|-]<n> ... File's status was last changed n minutes ago." echo " --cmin [+|-]<n> ... File's status was last changed n minutes ago."
echo " act find cmin argument (+n : greater than n, -n : less than n, n : exactly n)" echo " act find cmin argument (+n : greater than n, -n : less than n, n : exactly n)"
echo "Examples:" echo "Examples:"
echo " optimize all jpg images in /var/www/images" echo " optimize all jpg images in /var/www/images"
echo " img-optimize --jpg /var/www/images" echo " img-optimize --jpg --path /var/www/images"
echo "" echo ""
return 0 return 0
} }
@ -54,42 +55,22 @@ else
case "$1" in case "$1" in
--jpg) --jpg)
JPG_OPTIMIZATION="y" JPG_OPTIMIZATION="y"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;; ;;
--png) --png)
PNG_OPTIMIZATION="y" PNG_OPTIMIZATION="y"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;; ;;
--nowebp) --nowebp)
JPG_OPTIMIZATION="y" JPG_OPTIMIZATION="y"
PNG_OPTIMIZATION="y" PNG_OPTIMIZATION="y"
WEBP_OPTIMIZATION="n" WEBP_OPTIMIZATION="n"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;; ;;
--webp) --webp)
WEBP_OPTIMIZATION="y" WEBP_OPTIMIZATION="y"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;; ;;
--all) --all)
PNG_OPTIMIZATION="y" PNG_OPTIMIZATION="y"
JPG_OPTIMIZATION="y" JPG_OPTIMIZATION="y"
WEBP_OPTIMIZATION="y" WEBP_OPTIMIZATION="y"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;; ;;
-i | --interactive) -i | --interactive)
INTERACTIVE_MODE="1" INTERACTIVE_MODE="1"
@ -102,7 +83,12 @@ else
--cmin) --cmin)
if [ "$2" ]; then if [ "$2" ]; then
FIND_ARGS+="-cmin $2" FIND_ARGS+="-cmin $2"
shift shift
fi
;;
--path)
if [ "$2" ]; then
IMG_PATH="$2"
fi fi
;; ;;
-h | --help | help) -h | --help | help)