From a4a08e75d55ba1c456fd22c8fff94997b5b07b1f Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 2 May 2020 20:44:02 -0500 Subject: Add force option --- licenser | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'licenser') diff --git a/licenser b/licenser index 2bca223..f3e5480 100755 --- a/licenser +++ b/licenser @@ -7,7 +7,9 @@ __DEFAULT_LICENSE=MIT # entry point licenser() { - while getopts hly:a:o: OPT; do + _force=false + + while getopts hlfy:a:o: OPT; do case "$OPT" in h) usage @@ -17,6 +19,7 @@ licenser() { list_licenses exit 0 ;; + f) _force=true ;; y) __YEAR="$OPTARG-01-01" ;; a) __AUTHOR="$OPTARG" ;; o) __OUTPUT="$OPTARG" ;; @@ -45,7 +48,7 @@ licenser() { exit 2 fi - if [[ -e "$__OUTPUT" ]]; then + if [[ -e "$__OUTPUT" && ! $_force ]]; then echo "File exists: $__OUTPUT" exit 3 fi @@ -65,6 +68,7 @@ usage: licenser [-h|-l] [-y YEAR] [-a AUTHOR] [-o FILE] LICENSE -h show this help and exit -l list available licenses and exit + -f overwrite existing license -y YEAR set the copyright date to YEAR -a AUTHOR set the copyright holder to AUTHOR -o FILE output to FILE -- cgit 1.4.1-21-gabe81