diff options
-rwxr-xr-x | licenser | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/licenser b/licenser index 7d710d3..2337470 100755 --- a/licenser +++ b/licenser | |||
@@ -7,7 +7,7 @@ | |||
7 | # Constants | 7 | # Constants |
8 | ## where to download licenses from | 8 | ## where to download licenses from |
9 | PRGN="${0##*/}" | 9 | PRGN="${0##*/}" |
10 | LICENSER_SOURCE="https://git.sr.ht/~acdw/licenser-licenses/blob/master" | 10 | : "${LICENSER_SOURCE:=https://git.sr.ht/~acdw/licenser-licenses/blob/master}" |
11 | LICENSER_CACHE="${XDG_DATA_HOME:-$HOME/.local/share}/licenser" | 11 | LICENSER_CACHE="${XDG_DATA_HOME:-$HOME/.local/share}/licenser" |
12 | LICENSER_LICENSE="${LICENSER_LICENSE:-MIT}" | 12 | LICENSER_LICENSE="${LICENSER_LICENSE:-MIT}" |
13 | EXEC="${EXEC:-true}" | 13 | EXEC="${EXEC:-true}" |
@@ -16,12 +16,13 @@ usage() { | |||
16 | cat <<EOF | 16 | cat <<EOF |
17 | $PRGN: plop a license in your project | 17 | $PRGN: plop a license in your project |
18 | 18 | ||
19 | usage: $PRGN [-h|-m] | 19 | usage: $PRGN [-h|-m|-M] |
20 | $PRGN [-f] [-q] [-y YEAR] [-a AUTHOR] [-e EMAIL] | 20 | $PRGN [-f] [-q] [-y YEAR] [-a AUTHOR] [-e EMAIL] |
21 | [-l LANG] [-o FILE] [LICENSE] | 21 | [-l LANG] [-o FILE] [LICENSE] |
22 | flags: | 22 | flags: |
23 | -h show this help and exit | 23 | -h show this help and exit |
24 | -m list available licenses and exit | 24 | -m list available licenses and exit |
25 | -M list licenses, disregarding cached manifest | ||
25 | -f overwrite existing license | 26 | -f overwrite existing license |
26 | -q quiet: don't log anything | 27 | -q quiet: don't log anything |
27 | options: | 28 | options: |
@@ -55,7 +56,7 @@ licenser() { | |||
55 | __OUT=LICENSE # default output file | 56 | __OUT=LICENSE # default output file |
56 | __LANG=en # default to en because it's got the most licenses XXX | 57 | __LANG=en # default to en because it's got the most licenses XXX |
57 | 58 | ||
58 | while getopts hmfqy:a:e:o:l: OPT; do | 59 | while getopts hmMfqy:a:e:o:l:s: OPT; do |
59 | case "$OPT" in | 60 | case "$OPT" in |
60 | h) | 61 | h) |
61 | usage | 62 | usage |
@@ -66,6 +67,10 @@ licenser() { | |||
66 | list_licenses | 67 | list_licenses |
67 | exit "$?" | 68 | exit "$?" |
68 | ;; | 69 | ;; |
70 | M) | ||
71 | list_licenses -f | ||
72 | exit "$?" | ||
73 | ;; | ||
69 | q) _quiet=true ;; | 74 | q) _quiet=true ;; |
70 | y) __YEAR="$OPTARG" ;; | 75 | y) __YEAR="$OPTARG" ;; |
71 | a) __AUTHOR="$OPTARG" ;; | 76 | a) __AUTHOR="$OPTARG" ;; |
@@ -96,7 +101,7 @@ licenser() { | |||
96 | cat "$__CACHED" | 101 | cat "$__CACHED" |
97 | put | 102 | put |
98 | put "_END_LICENSE_" | 103 | put "_END_LICENSE_" |
99 | )" > "$__OUT" | 104 | )" >"$__OUT" |
100 | 105 | ||
101 | log "$__LICENSE written to $__OUT." | 106 | log "$__LICENSE written to $__OUT." |
102 | } | 107 | } |
@@ -125,6 +130,8 @@ list_licenses() { | |||
125 | cached="$LICENSER_CACHE/manifest" | 130 | cached="$LICENSER_CACHE/manifest" |
126 | source="$LICENSER_SOURCE/manifest" | 131 | source="$LICENSER_SOURCE/manifest" |
127 | 132 | ||
133 | [ "x$1" = "x-r" ] && rm "$cached" | ||
134 | |||
128 | mkdir -p "$LICENSER_CACHE" | 135 | mkdir -p "$LICENSER_CACHE" |
129 | log "Checking cache for manifest..." | 136 | log "Checking cache for manifest..." |
130 | if [ ! -f "$cached" ]; then | 137 | if [ ! -f "$cached" ]; then |
@@ -163,7 +170,7 @@ email() { | |||
163 | if [ -z "$__EMAIL" ]; then | 170 | if [ -z "$__EMAIL" ]; then |
164 | __EMAIL="$(git config --get user.email)" # try from git | 171 | __EMAIL="$(git config --get user.email)" # try from git |
165 | fi | 172 | fi |
166 | [ -n "$__EMAIL" ] && put "$__EMAIL" | 173 | [ -n "$__EMAIL" ] && put "<$__EMAIL>" |
167 | } | 174 | } |
168 | 175 | ||
169 | # helpers | 176 | # helpers |