shell-base/script
Simon Vieille 374ac3aeb9
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
feat(help): add help function
2023-01-08 15:18:23 +01:00

44 lines
454 B
Bash
Executable file

#!/bin/sh
usage() {
printf "Usage: %s [-h]\n" "$0"
}
help() {
cat << EOH
SYNOPSIS
$0 [-h]
DESCRIPTION
$0 does things!
OPTIONS
-h Show this help
EOH
}
on_interrupt() {
print "Process aborted!\n"
exit 130
}
main() {
while getopts "hf:" option; do
case "${option}" in
h) help; exit 0;;
f) FOO="$OPTARG";;
*) usage; exit 1;;
esac
done
FOO="${FOO:-defaultValue}"
exit 0
}
trap on_interrupt INT
main "$@"