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 --- LICENSE | 18 +++++++++++++++--- licenser | 8 ++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index f973b4b..44c8493 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,19 @@ Copyright 2020 Case Duckworth -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. 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