From: Steven Baltakatei Sandoval Date: Tue, 11 Apr 2023 20:41:51 +0000 (+0000) Subject: feat(user/mw_create_month_journal_range):Add mw script X-Git-Tag: 0.8.2^2~16 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/61078d978341cfc73018bced63353ab8a150066a?ds=inline;hp=-c feat(user/mw_create_month_journal_range):Add mw script - Note: Creates journal month boilerplate for year range 1582/2100. --- 61078d978341cfc73018bced63353ab8a150066a diff --git a/user/mw_create_month_journal_range.sh b/user/mw_create_month_journal_range.sh new file mode 100644 index 0000000..f2846b5 --- /dev/null +++ b/user/mw_create_month_journal_range.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Depends: BK-2020-03: mw_create_month_journal.sh +# Version: 0.0.1 + +# update each run +path_cmj="$HOME/git-OC/BK-2020-03..bkexdev/user/mw_create_month_journal.sh"; +year_start="1582"; +year_end="2100"; + +# plumbing +dir_out="./wikicode/"; + +yell() { echo "$0: $*" >&2; } # print script path and all args to stderr +die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status +must() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails +check_depends() { + # check location of `mw_create_month_journal.sh` + if [[ ! -f "$path_cmj" ]]; then die "FATAL:Not found:$path_cmj"; fi; +}; +check_plumbing() { + if [[ ! -d "$dir_out" ]]; then + yell "STATUS:Creating missing dir_out:$dir_out"; + mkdir -p "$dir_out"; fi; +}; +main() { + check_depends; + check_plumbing; + + while read -r year; do + while read -r month; do + monthp="$(printf "%2d" "$month")"; + # Define and execute create monthly journal command + cmj_args+=("$year"); + cmj_args+=("$month"); + + # Define output file path + path_out="$dir_out"/"$(printf "%d-%02d" "$year" "$month")"; + + # Execute + "$path_cmj" "${cmj_args[@]}" > "$path_out"; + + unset cmj_args; + done < <(seq 1 12); # each month + done < <(seq "$year_start" "$year_end"); # each year +}; + +main "$@"; + +# Author: Steven Baltakatei Sandoval +# License: GPlv3+