Skip to content

Commit

Permalink
feat(logging): per-file reporting is now opt-in via a --verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nwtn authored and JamieMason committed Feb 9, 2016
1 parent dde6088 commit 4c9a489
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 32 deletions.
21 changes: 11 additions & 10 deletions README.md
Expand Up @@ -96,16 +96,17 @@ these guides.

Options:

-d, --directory directory of images to process
-a, --image-alpha pre-process PNGs with ImageAlpha.app *
-j, --jpeg-mini pre-process JPGs with JPEGmini.app **
-m, --min-quality pngquant min quality parameter
-s, --skip-if-larger pngquant use --skip-if-larger
-q, --quit quit all apps when complete
-c, --no-color disable color output
-h, --help display this usage information
-e, --examples display some example commands and uses
-v, --version display the version number
-d, --directory directory of images to process
-a, --image-alpha pre-process PNGs with ImageAlpha.app *
-j, --jpeg-mini pre-process JPGs with JPEGmini.app **
-m, --min-quality pngquant min quality parameter
-s, --skip-if-larger pngquant use --skip-if-larger
-q, --quit quit all apps when complete
-c, --no-color disable color output
-h, --help display this usage information
-e, --examples display some example commands and uses
-v, --version display the version number
--verbose display detailed, per-file info on optimizations

* http://pngmini.com
** https://itunes.apple.com/us/app/jpegmini/id498944723
Expand Down
3 changes: 3 additions & 0 deletions bin/imageOptim
Expand Up @@ -49,6 +49,9 @@ while [ "$1" != "" ]; do
examples;
exit 0
;;
--verbose )
IS_VERBOSE="true"
;;
-v | --version )
echo $VERSION;
exit 0
Expand Down
28 changes: 17 additions & 11 deletions bin/imageOptimBashLib
Expand Up @@ -70,6 +70,9 @@ HAS_IMAGEMAGICK="false"
# {BooleanString} Whether to disable ANSI colour output.
NO_COLOR="false"

# {BooleanString} Whether to print detailed information about the optimizations
IS_VERBOSE="false"

# ------------------------------------
# LOGGING UTILS
# ------------------------------------
Expand Down Expand Up @@ -131,16 +134,17 @@ function usage {
echo ""
echo "Options:"
echo ""
echo " -d, --directory directory of images to process"
echo " -a, --image-alpha pre-process PNGs with ImageAlpha.app *"
echo " -j, --jpeg-mini pre-process JPGs with JPEGmini.app **"
echo " -m, --min-quality pngquant min quality parameter"
echo " -s, --skip-if-larger pngquant use --skip-if-larger"
echo " -q, --quit quit all apps when complete"
echo " -c, --no-color disable color output"
echo " -h, --help display this usage information"
echo " -e, --examples display some example commands and uses"
echo " -v, --version display the version number"
echo " -d, --directory directory of images to process"
echo " -a, --image-alpha pre-process PNGs with ImageAlpha.app *"
echo " -j, --jpeg-mini pre-process JPGs with JPEGmini.app **"
echo " -m, --min-quality pngquant min quality parameter"
echo " -s, --skip-if-larger pngquant use --skip-if-larger"
echo " -q, --quit quit all apps when complete"
echo " -c, --no-color disable color output"
echo " -h, --help display this usage information"
echo " -e, --examples display some example commands and uses"
echo " -v, --version display the version number"
echo " --verbose display detailed, per-file info on optimizations"
echo ""
echo "* http://pngmini.com"
echo "** https://itunes.apple.com/us/app/jpegmini/id498944723"
Expand Down Expand Up @@ -236,7 +240,9 @@ function output_savings {
fi
local actual_quality=$(bc <<< "scale=2; $actual_quality+$quality_loss")
fi
render_result "$source_file" $size_before $size_after $quality_loss
if [[ $IS_VERBOSE == "true" ]]; then
render_result "$source_file" $size_before $size_after $quality_loss
fi
fi
done
render_result "TOTAL" $total_before $total_after $quality_loss
Expand Down
3 changes: 3 additions & 0 deletions src/imageOptim
Expand Up @@ -49,6 +49,9 @@ while [ "$1" != "" ]; do
examples;
exit 0
;;
--verbose )
IS_VERBOSE="true"
;;
-v | --version )
echo $VERSION;
exit 0
Expand Down
7 changes: 6 additions & 1 deletion src/imageOptimBashLib
Expand Up @@ -70,6 +70,9 @@ HAS_IMAGEMAGICK="false"
# {BooleanString} Whether to disable ANSI colour output.
NO_COLOR="false"

# {BooleanString} Whether to print detailed information about the optimizations
IS_VERBOSE="false"

# ------------------------------------
# LOGGING UTILS
# ------------------------------------
Expand Down Expand Up @@ -179,7 +182,9 @@ function output_savings {
fi
local actual_quality=$(bc <<< "scale=2; $actual_quality+$quality_loss")
fi
render_result "$source_file" $size_before $size_after $quality_loss
if [[ $IS_VERBOSE == "true" ]]; then
render_result "$source_file" $size_before $size_after $quality_loss
fi
fi
done
render_result "TOTAL" $total_before $total_after $quality_loss
Expand Down
21 changes: 11 additions & 10 deletions src/usage.txt
Expand Up @@ -2,16 +2,17 @@ Usage: imageoptim [options]

Options:

-d, --directory directory of images to process
-a, --image-alpha pre-process PNGs with ImageAlpha.app *
-j, --jpeg-mini pre-process JPGs with JPEGmini.app **
-m, --min-quality pngquant min quality parameter
-s, --skip-if-larger pngquant use --skip-if-larger
-q, --quit quit all apps when complete
-c, --no-color disable color output
-h, --help display this usage information
-e, --examples display some example commands and uses
-v, --version display the version number
-d, --directory directory of images to process
-a, --image-alpha pre-process PNGs with ImageAlpha.app *
-j, --jpeg-mini pre-process JPGs with JPEGmini.app **
-m, --min-quality pngquant min quality parameter
-s, --skip-if-larger pngquant use --skip-if-larger
-q, --quit quit all apps when complete
-c, --no-color disable color output
-h, --help display this usage information
-e, --examples display some example commands and uses
-v, --version display the version number
--verbose display detailed, per-file info on optimizations

* http://pngmini.com
** https://itunes.apple.com/us/app/jpegmini/id498944723

0 comments on commit 4c9a489

Please sign in to comment.