From 9d48e187cd2cf0ce7aaf7b41bf4d8e94dd03b629 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 2 May 2020 20:41:08 -0500 Subject: Initial commit --- LICENSE | 7 ++++ licenser | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 LICENSE create mode 100755 licenser diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f973b4b --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +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: + +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. diff --git a/licenser b/licenser new file mode 100755 index 0000000..260724e --- /dev/null +++ b/licenser @@ -0,0 +1,144 @@ +#!/bin/bash +# licenser: do a license + +# defaults +__DEFAULT_LICENSE=MIT +: "${LICENSER_LICENSE:=$__DEFAULT_LICENSE}" + +# entry point +licenser() { + while getopts hly:a:o: OPT; do + case "$OPT" in + h) + usage + exit 0 + ;; + l) + list_licenses + exit 0 + ;; + y) __YEAR="$OPTARG-01-01" ;; + a) __AUTHOR="$OPTARG" ;; + o) __OUTPUT="$OPTARG" ;; + *) + usage + exit 1 + ;; + esac + done + shift $((OPTIND - 1)) + __LICENSE="${1:-$LICENSER_LICENSE}" + + # fill in blanks + [[ -z "$__YEAR" ]] && __YEAR="$(date +%F)" + [[ -z "$__AUTHOR" ]] && __AUTHOR="$(git config --get user.name)" + [[ -z "$__AUTHOR" ]] && __AUTHOR="$( + getent passwd "$USER" | awk -F: '{sub(/,+/,"",$5);print $5}' + )" + [[ -z "$__AUTHOR" ]] && __AUTHOR="$USER" + [[ -z "$__OUTPUT" ]] && __OUTPUT=LICENSE + + if ! type "licenser_$__LICENSE" >/dev/null 2>&1; then + echo "Unknown license: $__LICENSE" + echo "Available licenses:" + list_licenses + exit 2 + fi + + if [[ -e "$__OUTPUT" ]]; then + echo "File exists: $__OUTPUT" + exit 3 + fi + + "licenser_$__LICENSE" >"$__OUTPUT" +} + +list_licenses() { + declare -F | awk '/licenser_/{sub(/licenser_/,"",$NF); print $NF;}' +} + +usage() { + cat < + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. +END +} + +# enable sourcing or executing +if [[ ${BASH_SOURCE[0]} == "$0" ]]; then + licenser "$@" +fi -- cgit 1.4.1-21-gabe81