From e9926096a186791e30d094cf30585033c8943b60 Mon Sep 17 00:00:00 2001
From: Case Duckworth
Date: Sun, 10 May 2020 19:03:46 -0500
Subject: Enable licenser_source to be set by env

---
 licenser | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/licenser b/licenser
index 7d710d3..2337470 100755
--- a/licenser
+++ b/licenser
@@ -7,7 +7,7 @@
 # Constants
 ## where to download licenses from
 PRGN="${0##*/}"
-LICENSER_SOURCE="https://git.sr.ht/~acdw/licenser-licenses/blob/master"
+: "${LICENSER_SOURCE:=https://git.sr.ht/~acdw/licenser-licenses/blob/master}"
 LICENSER_CACHE="${XDG_DATA_HOME:-$HOME/.local/share}/licenser"
 LICENSER_LICENSE="${LICENSER_LICENSE:-MIT}"
 EXEC="${EXEC:-true}"
@@ -16,12 +16,13 @@ usage() {
 	cat <<EOF
 $PRGN: plop a license in your project
 
-usage:	$PRGN [-h|-m]
+usage:	$PRGN [-h|-m|-M]
 	$PRGN [-f] [-q] [-y YEAR] [-a AUTHOR] [-e EMAIL] 
 	      [-l LANG] [-o FILE] [LICENSE]
 flags:
 	-h	show this help and exit
 	-m	list available licenses and exit
+	-M	list licenses, disregarding cached manifest
 	-f	overwrite existing license
 	-q	quiet: don't log anything
 options:
@@ -55,7 +56,7 @@ licenser() {
 	__OUT=LICENSE # default output file
 	__LANG=en     # default to en because it's got the most licenses XXX
 
-	while getopts hmfqy:a:e:o:l: OPT; do
+	while getopts hmMfqy:a:e:o:l:s: OPT; do
 		case "$OPT" in
 		h)
 			usage
@@ -66,6 +67,10 @@ licenser() {
 			list_licenses
 			exit "$?"
 			;;
+		M)
+			list_licenses -f
+			exit "$?"
+			;;
 		q) _quiet=true ;;
 		y) __YEAR="$OPTARG" ;;
 		a) __AUTHOR="$OPTARG" ;;
@@ -96,7 +101,7 @@ licenser() {
 		cat "$__CACHED"
 		put
 		put "_END_LICENSE_"
-	)" > "$__OUT"
+	)" >"$__OUT"
 
 	log "$__LICENSE written to $__OUT."
 }
@@ -125,6 +130,8 @@ list_licenses() {
 	cached="$LICENSER_CACHE/manifest"
 	source="$LICENSER_SOURCE/manifest"
 
+	[ "x$1" = "x-r" ] && rm "$cached"
+
 	mkdir -p "$LICENSER_CACHE"
 	log "Checking cache for manifest..."
 	if [ ! -f "$cached" ]; then
@@ -163,7 +170,7 @@ email() {
 	if [ -z "$__EMAIL" ]; then
 		__EMAIL="$(git config --get user.email)" # try from git
 	fi
-	[ -n "$__EMAIL" ] && put "$__EMAIL"
+	[ -n "$__EMAIL" ] && put "<$__EMAIL>"
 }
 
 # helpers
-- 
cgit 1.4.1-21-gabe81