Skip to content

Commit

Permalink
add script to init comics dir
Browse files Browse the repository at this point in the history
  • Loading branch information
eth0net committed May 1, 2024
1 parent a7e6344 commit e1eeb3d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Comic files used for testing
/comics

# Generated by Cargo - compiled files and executables
/target

Expand Down
58 changes: 58 additions & 0 deletions scripts/init_comics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -eo pipefail

# Global variable for quiet mode
QUIET=""

# Function to log messages with optional indentation
log() {
# Terminate early if quiet mode is enabled
[[ -n "$QUIET" ]] && return

# Add spaces for indentation based on the current function call depth
local indentation=""
for ((i=0; i<FUNCNEST; i++)); do
indentation+=" "
done

# Print message to stderr
>&2 echo "${indentation}>> $1"
}

# Function to remove old comics directory
function remove_comics {
log "Removing old comics directory"
rm -rf comics
}

# Function to create new directories
function create_dirs {
log "Creating new directories"
mkdir -p comics/in comics/out
}

# Function to create new files
function create_files {
log "Creating new files"
touch "comics/in/Alpha 001 (2024).cbz"
touch "comics/in/Beta 000 (2024).cbr"
}

# Parse command-line options
while getopts "q" opt; do
case ${opt} in
q ) # Quiet mode, suppress log output
QUIET="true"
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
esac
done
shift $((OPTIND -1))

# Main script logic
remove_comics
create_dirs
create_files

0 comments on commit e1eeb3d

Please sign in to comment.