]> git.treefish.org Git - bitvalue.git/commitdiff
Added help
authorAlexander Schmidt <alex@treefish.org>
Tue, 7 Nov 2017 23:24:53 +0000 (00:24 +0100)
committerAlexander Schmidt <alex@treefish.org>
Tue, 7 Nov 2017 23:24:53 +0000 (00:24 +0100)
bitvalue

index 617305eaa7fcd1df1138fd2d0a5ddc105f9a0b28..831145d3db5d868c0efa37ede7fb80655fa22ad3 100755 (executable)
--- a/bitvalue
+++ b/bitvalue
@@ -2,6 +2,34 @@
 
 CONFIG=~/.bitvaluerc
 
+USAGE="Usage: $(basename "$0") [-h] [-t val]
+Simple bash script to visualize the value of your bitcoin investment.
+
+Arguments:
+  -h  show this help text
+  -t  set the timespan (default: 30d)"
+
+TIMESPAN="30d"
+
+while getopts ':ht:' option; do
+    case "$option" in
+       h) echo "$USAGE"
+          exit
+          ;;
+       t) TIMESPAN=$OPTARG
+          ;;
+       :) printf "missing argument for -%s\n" "$OPTARG" >&2
+          echo "$usage" >&2
+          exit 1
+          ;;
+       \?) printf "illegal option: -%s\n" "$OPTARG" >&2
+           echo "$usage" >&2
+           exit 1
+           ;;
+    esac
+done
+shift $((OPTIND - 1))
+
 if [ ! -f $CONFIG ]; then
     cat << EOF > $CONFIG
 EXCHANGE="bitstamp"
@@ -14,12 +42,6 @@ fi
 
 source $CONFIG
 
-if [ ! -z "$1" ]; then
-    TIMESPAN="$1"
-else
-    TIMESPAN="30d"
-fi
-
 cat << EOF | gnuplot
 set terminal dumb
 set datafile separator ","