From c45684346906c4a3af31fa1af0627c978685c5de Mon Sep 17 00:00:00 2001 From: James Tomasino Date: Sat, 20 Jan 2018 01:23:53 -0500 Subject: [PATCH] add template for burrow source --- burrow | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/burrow b/burrow index e69de29..f809fcb 100644 --- a/burrow +++ b/burrow @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +shopt -s extglob +configfile="/path/to/file" + +function read_config() { + while IFS='= ' read lhs rhs + do + if [[ $lhs != *( )#* ]] + then + # Specify test conditions for settings here + declare $lhs=$rhs + fi + done < "$configfile" +} + +function show_help() { + cat > /dev/stdout << END +${0} [-h] + +REQUIRED ARGS: + + +OPTIONAL ARGS: +-h - show this help +-v - verbose logging + +END +} + +function parseopts() { + while getopts ":hv" opt + do + case "${opt}" in + h) + show_help + exit 0 + ;; + v) VERBOSE=1 ;; + *) + echo "Invalid option. Try -h for help." + exit 1 + esac + done + return $OPTIND +} + +function parseargs() { + for p in "$@" + do + args+=("$p") + done +} + +function main() { + parseopts "$@" + parseargs "${@:$?}" + + if [[ ${VERBOSE} -gt 0 ]] + then + set -x + fi +} + +main "$@"