Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add -v|--verbose flag #57

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions webize
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ usage() {
echo ' If omitted, image search is recursive'
echo ' clean [--scoped] <dir> Cleanup index.htm'
echo " -s|--scoped Scope index.htm to each descendent directory"
echo 'Options:'
echo " -v|--verbose Verbose"
echo 'Examples: '
echo ' # Linux: Generate index.htm in /path/to for all descendent image files, and opens it in firefox'
echo ' ./webize gallery /path/to | xargs firefox'
Expand Down Expand Up @@ -44,6 +46,10 @@ while test $# -gt 0; do
SCOPED=1
shift
;;
-v|--verbose)
VERBOSE=1
shift
;;
*)
DIR="$1"
shift
Expand All @@ -56,6 +62,7 @@ DIR=${DIR:-}
GALLERY=${GALLERY:-}
CLEAN=${CLEAN:-}
SCOPED=${SCOPED:-}
VERBOSE=${VERBOSE:-}

# Normalization
DIR=$( echo "$DIR" | sed 's@/$@@' ) # Trim trailing '/'
Expand Down Expand Up @@ -84,6 +91,9 @@ fi
# Generate a index.htm in current directory
if [ -n "$GALLERY" ]; then
echo "$DIRS" | while read -r d; do
if [ -n "$VERBOSE" ]; then
echo "Searching directory: $d" >&2
fi
IMAGES_REGEX='(\.gif|\.jpe?g|\.png|\.svg|\.webp)$'
IMAGES=$(
if [ -n "$SCOPED" ]; then
Expand Down Expand Up @@ -975,6 +985,9 @@ fi
# Remove index.htm in each directory
if [ -n "$CLEAN" ]; then
echo "$DIRS" | while read -r d; do
if [ -n "$VERBOSE" ]; then
echo "Searching directory: $d" >&2
fi
INDEX_HTM="$d/index.htm"
if [ -f "$INDEX_HTM" ]; then
rm -f "$INDEX_HTM"
Expand Down