Added getopts
This commit is contained in:
28
gitistics.sh
28
gitistics.sh
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Specify a directory with all Git repositories
|
# Specify a directory with all Git repositories
|
||||||
REPODIR=~/Git
|
REPODIR=$(pwd)
|
||||||
|
|
||||||
# Regex or fixed name (brackets need to be escaped with a backslash)
|
# Regex or fixed name (brackets need to be escaped with a backslash)
|
||||||
REPOUSER="\(structix\|Janek\)"
|
REPOUSER="\(structix\|Janek\)"
|
||||||
@@ -10,7 +10,7 @@ REPOUSER="\(structix\|Janek\)"
|
|||||||
STARTDATE="01 Jan 2018"
|
STARTDATE="01 Jan 2018"
|
||||||
|
|
||||||
# Verbose flag
|
# Verbose flag
|
||||||
VERBOSE=true
|
VERBOSE=false
|
||||||
|
|
||||||
# --------------------
|
# --------------------
|
||||||
# --- functions
|
# --- functions
|
||||||
@@ -107,5 +107,29 @@ function main() {
|
|||||||
echo "Total deletions: $totaldeletions"
|
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 <directory> 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
|
# Start the main function
|
||||||
main
|
main
|
||||||
|
Reference in New Issue
Block a user