about summary refs log tree commit diff stats
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xpkgs/by-name/st/stamp/stamp.sh40
1 files changed, 22 insertions, 18 deletions
diff --git a/pkgs/by-name/st/stamp/stamp.sh b/pkgs/by-name/st/stamp/stamp.sh
index 10ede809..7d71c403 100755
--- a/pkgs/by-name/st/stamp/stamp.sh
+++ b/pkgs/by-name/st/stamp/stamp.sh
@@ -8,19 +8,22 @@ help() {
 A simply file copyright menagment system
 
 USAGE:
-    stamp [OPTIONS] FILE_OR_DIRECTORY
+    stamp [OPTIONS] COMMAND
 
 OPTIONS:
     --help      | -h
                             Display this help and exit.
 
-    --version   | -v
-                            Display version and copyright information and exit.
-
     --license   | -l L
                             Specify a license.
+COMMANDS:
+    copyright FILES_OR_DIRECTORIES
+                            Add your copyright information to this file [this is the default command].
+
+    c FILES_OR_DIRECTORIES
+                            An alias for the copyright above.
 ARGUMENTS:
-    FILE_OR_DIRECTORY := [[fd . --max-depth 3]]
+    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
@@ -51,13 +54,11 @@ for arg in "$@"; do
         help
         exit 0
         ;;
-    "--version" | "-v")
-        version
-        exit 0
-        ;;
     esac
 done
 
+[ "$(git rev-parse --is-inside-work-tree)" = "true" ] || die "You need to be in a git directory"
+
 while [ "$#" -gt 0 ]; do
     case "$1" in
     "--license" | "-l")
@@ -66,19 +67,22 @@ while [ "$#" -gt 0 ]; do
         [ "$license" ] || die "No license specified. See --help for more."
         shift 1
         ;;
-    *)
-        file="$1"
+    "copyright" | "c")
         shift 1
+        # The files should now be in $@
+        break
         ;;
     esac
 done
 
-if [ -d "$file" ]; then
-    fd . "$file" --type file | while read -r path_file; do
-        reuse_run "$path_file"
-    done
-else
-    reuse_run "$file"
-fi
+for file in "$@"; do
+    if [ -d "$file" ]; then
+        fd . "$file" --type file | while read -r path_file; do
+            reuse_run "$path_file"
+        done
+    else
+        reuse_run "$file"
+    fi
+done
 
 # vim: ft=sh