feat(user/):Add wrapper for mw_create_summary_months.sh
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Sun, 9 Jul 2023 00:27:35 +0000 (00:27 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Sun, 9 Jul 2023 00:27:35 +0000 (00:27 +0000)
- chore(user/mw_create_year_journal_range.sh): Fix license statement.

new file:   user/mw_create_summary_months_range.sh

user/mw_create_summary_months_range.sh [new file with mode: 0755]
user/mw_create_year_journal_range.sh

diff --git a/user/mw_create_summary_months_range.sh b/user/mw_create_summary_months_range.sh
new file mode 100755 (executable)
index 0000000..ca97b06
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# Desc: Wrapper for creating yearly journal summary page generation script
+# Input: arg1: path mw_create_summary_months.sh
+#        arg2: year start
+#        arg3: year end
+# Example: mw_create_summary_months_range.sh ./mw_create_summary_months.sh 2030 2040
+# Depends: BK-2020-03: mw_create_summary_months.sh
+# Version: 0.0.1
+
+# plumbing
+path_gen="$1"; # eg "$HOME/scripts/mw_create_year_journal.sh"
+year_start="$2"; # eg 2030
+year_end="$3"; # eg 2040
+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_year_journal.sh`
+    if [[ ! -f "$path_gen" ]]; then die "FATAL:Not found:$path_gen"; 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
+        gen_args+=("$year");
+        
+        # Define output file path
+        path_out="$dir_out"/"$(printf "Summary_of_months_of_%d" "$year")";
+        
+        # Execute
+        "$path_gen" "${gen_args[@]}" > "$path_out";
+        
+        unset gen_args;
+    done < <(seq "$year_start" "$year_end"); # each year
+}; # main program
+
+main "$@";
+
+# Author: Steven Baltakatei Sandoval
+# License: GPLv3+
index 63694ecb8064f53af4f70ee1957fbdec57425ad8..71ffd1d456651fd4d22098123c0636193f63dd24 100755 (executable)
@@ -5,7 +5,7 @@
 #        arg3: year end
 # Example: mw_create_year_journal_range.sh ./mw_create_year_journal.sh 2030 2040
 # Depends: BK-2020-03: mw_create_year_journal.sh
 #        arg3: year end
 # Example: mw_create_year_journal_range.sh ./mw_create_year_journal.sh 2030 2040
 # Depends: BK-2020-03: mw_create_year_journal.sh
-# Version: 0.0.1
+# Version: 0.0.2
 
 # plumbing
 path_cyj="$1"; # eg "$HOME/scripts/mw_create_year_journal.sh"
 
 # plumbing
 path_cyj="$1"; # eg "$HOME/scripts/mw_create_year_journal.sh"
@@ -45,4 +45,4 @@ main() {
 main "$@";
 
 # Author: Steven Baltakatei Sandoval
 main "$@";
 
 # Author: Steven Baltakatei Sandoval
-# License: GPlv3+
+# License: GPLv3+