Skip to content

Commit

Permalink
fix pre-process zip archive expansion default; close #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Pennebaker committed Sep 18, 2024
1 parent ac0f6f1 commit 88c94e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Use `-n` to specify batch size.

Use `-p` to specify target directory prefix.

See `harmonica -h` for more detail.
See `harmonica -h` for more options.

# ABOUT

Expand Down
26 changes: 22 additions & 4 deletions bin/harmonica
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ set -euf
HARMONICA_VERSION='0.0.2'
PREFIX='issue-'
BATCH_CAPACITY='0'
PRE_PROCESS_ZIP='1'
PRE_PROCESS_ZIP='0'
ASSETS=''
POST_PROCESS_CBZ='0'
LF='
'
Expand All @@ -16,6 +17,7 @@ usage() {
echo "-p <prefix>\tcustomize target prefix (default: \"[../]${PREFIX}\")"
echo "-n <limit>\tapply uniform directory size (default: source entries / 2)"
echo "-u\t\tpre-process expand cbz/zip archive (default: false)"
echo "-b <assets>\tcopy boilerplate assets (comma separated) to each batch (default: '')"
echo "-z\t\tpost-process cbz archival (default: false)"
echo "-v\t\tshow version"
echo "-h\t\tshow usage menu"
Expand Down Expand Up @@ -51,6 +53,17 @@ for ARG in $ARGS; do
PRE_PROCESS_ZIP='1'
shift
;;
-b)
shift

if [ "$#" -lt 1 ]; then
usage
exit 1
fi

ASSETS="$1"
shift
;;
-z)
POST_PROCESS_CBZ='1'
shift
Expand Down Expand Up @@ -104,12 +117,17 @@ I=1
find_source |
sort |
xargs -n "$BATCH_CAPACITY" |
while IFS= read -r "-d${LF}" fs; do
while IFS= read -r "-d${LF}" FS; do
TARGET="${PREFIX}${I}"
mkdir -p "$TARGET"

for f in $fs; do
cp "$f" "$TARGET"
for F in $FS; do
cp "$F" "$TARGET"
done

echo "${ASSETS}," |
while IFS= read -r '-d,' ASSET; do
cp "$ASSET" "$TARGET"
done

if [ "$POST_PROCESS_CBZ" -eq '1' ]; then
Expand Down
Binary file added examples/0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/zzz.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 88c94e9

Please sign in to comment.