feat(unitproc/python/):Add EVA-2020-02-2 humidity conversions
[BK-2020-03.git] / user / mw_create_month_journal_range.sh
CommitLineData
61078d97
SBS
1#!/usr/bin/env bash
2# Depends: BK-2020-03: mw_create_month_journal.sh
3# Version: 0.0.1
4
5# update each run
6path_cmj="$HOME/git-OC/BK-2020-03..bkexdev/user/mw_create_month_journal.sh";
7year_start="1582";
8year_end="2100";
9
10# plumbing
11dir_out="./wikicode/";
12
13yell() { echo "$0: $*" >&2; } # print script path and all args to stderr
14die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status
15must() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails
16check_depends() {
17 # check location of `mw_create_month_journal.sh`
18 if [[ ! -f "$path_cmj" ]]; then die "FATAL:Not found:$path_cmj"; fi;
19};
20check_plumbing() {
21 if [[ ! -d "$dir_out" ]]; then
22 yell "STATUS:Creating missing dir_out:$dir_out";
23 mkdir -p "$dir_out"; fi;
24};
25main() {
26 check_depends;
27 check_plumbing;
28
29 while read -r year; do
30 while read -r month; do
31 monthp="$(printf "%2d" "$month")";
32 # Define and execute create monthly journal command
33 cmj_args+=("$year");
34 cmj_args+=("$month");
35
36 # Define output file path
37 path_out="$dir_out"/"$(printf "%d-%02d" "$year" "$month")";
38
39 # Execute
40 "$path_cmj" "${cmj_args[@]}" > "$path_out";
41
42 unset cmj_args;
43 done < <(seq 1 12); # each month
44 done < <(seq "$year_start" "$year_end"); # each year
45};
46
47main "$@";
48
49# Author: Steven Baltakatei Sandoval
50# License: GPlv3+