osh_dir_std 0.8.4

Helps humans and machines deal with the *OSH directory standard*: <https://github.com/hoijui/osh-dir-std>
Documentation
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2022 Robin Vobruba <hoijui.quaero@gmail.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# See the output of "$0 -h" for details.

# Exit immediately on each error and unset variable;
# see: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -Eeuo pipefail
#set -Eeu

script_dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
build_dir="$(pwd)/build"

APP_NAME="Project builder"

# parameters

function print_help() {

	script_name="$(basename "$0")"
	echo -e ""
	echo -e "$APP_NAME - Generates everything for this repo."
	echo -e ""
	echo -e "Usage:"
	echo -e "\t$script_name [OPTION...]"
	echo -e "Options:"
	echo -e "\t-h, --help"
	echo -e "\t\tPrint this usage help and exit"
	echo -e "Examples:"
	echo -e "\t$script_name"
	echo -e ""
}

# Process command line arguments
while [[ $# -gt 0 ]]
do
	arg="$1"
	shift # $2 -> $1, $3 -> $2, ...

	case "$arg" in
		-h|--help)
			print_help
			exit 0
			;;
		-*) # unknown switch
			>&2 echo "ERROR: Unknown switch '$arg'"
			exit 1
			;;
		*) # non-switch
			POSITIONAL+=("$arg") # save it in an array for later
			;;
	esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

if ! [ -d mod ]
then
	>&2 echo "ERROR: Please start this script from the project root (where the 'mod' dir is located)"
	exit 1
fi

for mod in mod/*
do
	if ! [ -d "$mod" ]
	then
		continue
	fi
	build_mod_dir="$build_dir/$mod"
	mkdir -p "$build_mod_dir"
	"$script_dir/def2lst" \
		"$mod/definition.csv" \
		> "$build_mod_dir/listing.txt"
	"$script_dir/lst2tree" \
		--html \
		--title "$(basename "$mod")" \
		--output "$build_mod_dir/tree.html" \
		< "$build_mod_dir/listing.txt"
done

mvd create_index \
	"$build_dir"