From 209300ef36196c3363d711e17c2a87b51a6d7a02 Mon Sep 17 00:00:00 2001 From: structix Date: Sun, 6 Jan 2019 18:18:07 +0100 Subject: [PATCH] Added getopts --- gitistics.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/gitistics.sh b/gitistics.sh index 261334d..e030b51 100755 --- a/gitistics.sh +++ b/gitistics.sh @@ -1,7 +1,7 @@ #!/bin/bash # Specify a directory with all Git repositories -REPODIR=~/Git +REPODIR=$(pwd) # Regex or fixed name (brackets need to be escaped with a backslash) REPOUSER="\(structix\|Janek\)" @@ -10,7 +10,7 @@ REPOUSER="\(structix\|Janek\)" STARTDATE="01 Jan 2018" # Verbose flag -VERBOSE=true +VERBOSE=false # -------------------- # --- functions @@ -107,5 +107,29 @@ function main() { echo "Total deletions: $totaldeletions" } + + + + +# process the arguments +print_usage() { + echo "$0 - git statistics over multiple directories" + echo "" + echo "options:" + echo "-h show this help page" + echo "-r set a directory with your repositories" + echo "-v show verbose output" +} + +while getopts 'r:vh' flag; do + case "${flag}" in + r) REPODIR="${OPTARG}" ;; + v) VERBOSE=true ;; + h) print_usage; exit 0 ;; + *) print_usage + exit 1 ;; + esac +done + # Start the main function main