#!/usr/bin/env bash # SPDX-FileCopyrightText: 2022 Robin Vobruba # 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" publish_dir="$(pwd)/public" APP_NAME="CI runner" # parameters check=false 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 "\t-c, --check-style" 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 ;; -c|--check-style) check=true ;; *) # unknown/non-switch POSITIONAL+=("$arg") # save it in an array for later ;; esac done set -- "${POSITIONAL[@]}" # restore positional parameters if $check then "$script_dir/test" "$@" else "$script_dir/build" "$@" echo "Files to be published to pages:" rm -Rf "$publish_dir" mv "$build_dir" "$publish_dir" find "$publish_dir" fi