about summary refs log tree commit diff stats
path: root/pkgs/by-name/st
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/st')
-rw-r--r--pkgs/by-name/st/stamp/package.nix1
-rwxr-xr-xpkgs/by-name/st/stamp/stamp.sh60
2 files changed, 36 insertions, 25 deletions
diff --git a/pkgs/by-name/st/stamp/package.nix b/pkgs/by-name/st/stamp/package.nix
index f39e2197..703f73e3 100644
--- a/pkgs/by-name/st/stamp/package.nix
+++ b/pkgs/by-name/st/stamp/package.nix
@@ -10,6 +10,7 @@ sysLib.writeShellScript {
   src = ./stamp.sh;
   generateCompletions = false;
   keepPath = false;
+
   dependencies = [
     findutils
     fd
diff --git a/pkgs/by-name/st/stamp/stamp.sh b/pkgs/by-name/st/stamp/stamp.sh
index c3697c99..0fced956 100755
--- a/pkgs/by-name/st/stamp/stamp.sh
+++ b/pkgs/by-name/st/stamp/stamp.sh
@@ -5,49 +5,48 @@ SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH
 
 help() {
     cat <<EOF
-A simply file copyright menagment system
+A simple file copyright management system.
 
 USAGE:
-    stamp [OPTIONS] COMMAND
+    stamp [OPTIONS] FILES_OR_DIRECTORIES
 
 OPTIONS:
-    --help      | -h
+    --help          | -h
                             Display this help and exit.
 
-    --license   | -l L
+    --license L     | -l L
                             Specify a license.
-COMMANDS:
-    copyright FILES_OR_DIRECTORIES
-                            Add your copyright information to this file [this is the default command].
+                            This defaults to the GPL-3.0-or-later.
 
-    c FILES_OR_DIRECTORIES
-                            An alias for the copyright above.
+    --copyright C   | -c C
+                            Specify a copyright string (e.g. name and email).
+                            By default this is constructed from the git user.name and user.email
 ARGUMENTS:
     FILES_OR_DIRECTORIES := [[ fd . --max-depth 3 ]]
                             Possible files to stamp.
 
     L                    := GPL-3.0-or-later|CC-BY-SA-4.0|AGPL-3.0-or-later
                             A possible license identifier. These above are only suggestions.
+
+    C                    := [[ true ]]
+                            This can be anything, which represents a copyright string.
+                            Commenly that is a combination of a name and an email.
 EOF
 }
 
 reuse_run() {
     root="$(git rev-parse --show-toplevel)"
 
+    template=""
     if [ -e "$root/.reuse/templates/default.jinja2" ]; then
-        reuse annotate \
-            --copyright "$(git config --get user.name) <$(git config --get user.email)>" \
-            --copyright-style string-c \
-            --template default \
-            --fallback-dot-license \
-            --license "$license" "$1"
-    else
-        reuse annotate \
-            --copyright "$(git config --get user.name) <$(git config --get user.email)>" \
-            --copyright-style string-c \
-            --fallback-dot-license \
-            --license "$license" "$1"
+        template="--template=default"
     fi
+
+    reuse annotate \
+        --copyright="$copyright" \
+        --copyright-prefix=string-c $template \
+        --fallback-dot-license \
+        --license="$license" -- "$1"
 }
 
 for arg in "$@"; do
@@ -62,21 +61,32 @@ done
 [ "$(git rev-parse --is-inside-work-tree)" = "true" ] || die "You need to be in a git directory"
 
 run=true
+license="GPL-3.0-or-later"
+copyright="$(git config --get user.name) <$(git config --get user.email)>"
 while [ "$#" -gt 0 ] && [ "$run" = true ]; do
     case "$1" in
     "--license" | "-l")
         shift 1
         license="$1"
-        [ "$license" ] || die "No license specified. See --help for more."
+        [ "$license" ] || die "No license specified. See --help for usage."
         shift 1
         ;;
-    "copyright" | "c")
+    "--copyright" | "-c")
+        shift 1
+        copyright="$1"
+        [ "$copyright" ] || die "No copyright string specified. See --help for usage."
         shift 1
-        # The files should now be in $@
+        ;;
+    "--")
         run=false
+        shift 1
+        ;;
+    -*)
+        die "Unknown option: '$1' (if you intented this to be a path use '--' before it.)"
         ;;
     *)
-        die "Unknown command: $1"
+        # We reached the end of the options.
+        run=false
         ;;
     esac
 done