Raclette/raclette

81 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# CONSTANTS
readonly PKGVER="0.0.1"
readonly LICENSE="GNU AGPLv3"
readonly ROOTPATH="$(dirname $(readlink -f $(which ${0})))"
readonly CONFIG="/usr/local/noveria/etc/raclette/config.json"
for util in ${ROOTPATH}/functions/*; do
source ${util}
done
# VARIABLES
declare debuglevel=3
declare dryrun=0
function usage() {
cat << EOF
usage: $(basename ${0}) <operation> [command] ...
operations:
$(basename ${0}) {-h --help}
$(basename ${0}) {-V --version}
$(basename ${0}) {-v --verbose}
$(basename ${0}) {-n --dryrun}
commands:
$(basename ${0}) config
EOF
}
function version() {
cat << EOF
Raclette v${PKGVER}
Copyright (C) 2024 Noveria Network
This program may be freely redistributed under
the terms of the ${LICENSE}
EOF
}
###
## SCRIPT START
###
while true; do
case "${1}" in
-h|--help)
usage
break
;;
-V|--version)
version
break
;;
-v|--verbose)
debuglevel=4
;;
-n|--dryrun)
dryrun=1
;;
config)
parent="$1"
cmd="$2"
shift; shift
type ${parent}_${cmd} &> /dev/null
if [[ $? -eq 0 ]]; then
${parent}_${cmd} $@
exit 0
fi
${parent}_help
exit 1
;;
*)
echo "Invalid argument. Type $(basename $0) -h for help!"
exit 1
;;
esac
shift
done
exit 0