From 4308699484e91053b471f64fdf29149087d8cd75 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 30 Jun 2022 17:28:12 -0500 Subject: Update to version 1.0 --- licenser | 181 --------------------------------------------------------------- 1 file changed, 181 deletions(-) delete mode 100755 licenser (limited to 'licenser') diff --git a/licenser b/licenser deleted file mode 100755 index 2337470..0000000 --- a/licenser +++ /dev/null @@ -1,181 +0,0 @@ -#!/bin/sh -# licenser: drop a little ol license in there -# Author: Case Duckworth -# License: MIT -# Version: 0.2 - -# Constants -## where to download licenses from -PRGN="${0##*/}" -: "${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}" - -usage() { - cat <"$__OUT" - - log "$__LICENSE written to $__OUT." -} - -# download a license, or get it from the cache -# if there's not one, return error -get_license() { - license="$1" - cached="$LICENSER_CACHE/$license/$__LANG" - source="$LICENSER_SOURCE/$license/$__LANG" - - mkdir -p "$LICENSER_CACHE/$license" - log "Checking cache for $license..." - if [ ! -f "$cached" ]; then - log "Not found. Downloading from $source..." - if ! curl -fLo "$cached" "$source"; then - log "License $license unavailable in language: $__LANG" - return 1 - fi - fi - put "$cached" -} - -# download a list of the licenses, or get it from the cache -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 - log "Not found. Downloading from $source..." - if ! curl -fLo "$cached" "$LICENSER_SOURCE/manifest"; then - log "Unable to get the manifest" - return 1 - fi - fi - cat "$cached" -} - -# template function for the copyright year -year() { - case "$__YEAR" in - '') # figure out the year - date +%Y ;; - *) # one was provided - put "$__YEAR" ;; - esac -} - -# template function for author/owner -author() { - if [ -z "$__AUTHOR" ]; then - __AUTHOR="$(git config --get user.name)" # try from git - [ -z "$__AUTHOR" ] && __AUTHOR="$( - getent passwd "$USER" | awk -F: '{sub(/,+/,"",$5);print $5}' - )" # or, try from getent - [ -z "$__AUTHOR" ] && __AUTHOR="$USER" # give up, get $USER - fi - put "$__AUTHOR" -} - -email() { - if [ -z "$__EMAIL" ]; then - __EMAIL="$(git config --get user.email)" # try from git - fi - [ -n "$__EMAIL" ] && put "<$__EMAIL>" -} - -# helpers -put() { printf '%s\n' "$*"; } -log() { $_quiet || put "$PRGN: $*" >&2; } - -# run -$EXEC && licenser "$@" -- cgit 1.4.1-21-gabe81