From 3304fde7a309c28031bc3e41671ff30468de4cc1 Mon Sep 17 00:00:00 2001 From: C-Duv Date: Sat, 11 Feb 2017 14:58:03 +0100 Subject: [PATCH] Adds "-h" option to display usage guide --- README.md | 5 ++++- send-notification.sh | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8d4a0a6..bd66e6b 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,14 @@ send-notification.sh "All your base are belong to us" ``` ``` - uptime | send-notification.sh +uptime | send-notification.sh ``` +See `send-notification.sh -h`. + ### Configuration : +Script can be configured Edit `send-notification.sh` and set the following variables: * `USER_LOGIN` diff --git a/send-notification.sh b/send-notification.sh index f22de58..cda4383 100644 --- a/send-notification.sh +++ b/send-notification.sh @@ -8,10 +8,25 @@ # # NĂ©cessite: sed, sh et wget # -# Possible usages: -# send-notification.sh "All your base are belong to us" -# echo "All your base are belong to us" | send-notification.sh -# uptime | send-notification.sh +# Possible usages: see usage_help() + + +readonly PROGNAME=$(basename $0) + +usage_help () { + echo "Possible usages:" + echo "* ${PROGNAME} [options] [message]" + echo "* echo \"All your base are belong to us\" | ${PROGNAME} [options]" + echo "" + echo "Options:" + echo "* -h display this help" +} + +while getopts "h" option; do + case "$option" in + h) usage_help ; exit 0 ;; + esac +done ##