Add "version" and "help" options

This commit is contained in:
Jérémy Lecour 2019-03-10 00:31:28 +01:00
parent d01e79e832
commit 0c6123bb54

View file

@ -4,8 +4,47 @@
# Dependencies (all OS): git postgresql-client
# Dependencies (Debian): sudo
# version 0.4.1
# Copyright 2007-2018 Gregory Colpart <reg@evolix.fr>, Jérémy Lecour <jlecour@evolix.fr>, Evolix <info@evolix.fr>
# version 0.5.0.beta1
# Copyright 2007-2019 Evolix <info@evolix.fr>, Gregory Colpart <reg@evolix.fr>,
# Jérémy Lecour <jlecour@evolix.fr> and others.
VERSION="0.5.0.beta1"
show_version() {
printf "%s\n" "evomaintenance version ${VERSION}"
}
show_help() {
cat <<END
$(show_version)
Copyright 2007-2019 Evolix <info@evolix.fr>, Gregory Colpart <reg@evolix.fr>,
Jérémy Lecour <jlecour@evolix.fr> and others.
evomaintenance comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
See the GNU General Public Licence for details.
evomaintenance is a program that helps reporting what you've done on a server
Usage: evomaintenance
or evomaintenance --message="add new host"
or evomaintenance --no-db --no-mail --no-commit
or echo "add new vhost | evomaintenance
Options
-m, --message=MESSAGE set the message from the command line
--mail enable the mail hook
--no-mail disable the mail hook
--db enable the database hook
--no-db disable the database hook
--commit enable the commit hook
--no-commit disable the commit hook
-v, --verbose increase verbosity
-n, --dry-run actions are not executed
--help print this message and exit
--version print version and exit
END
}
get_system() {
uname -s
@ -202,10 +241,14 @@ GIT_COMMITS=""
# based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
while :; do
case $1 in
# -h|-\?|--help) # Call a "show_help" function to display a synopsis, then exit.
# show_help
# exit
# ;;
-h|-\?|--help)
show_help
exit 0
;;
--version)
show_version
exit 0
;;
-m|--message)
# message options, with value speparated by space
if [ -n "$2" ]; then