blob: 10ede8096a82a55e332f46d56c9d5239127039ef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/usr/bin/env dash
# shellcheck source=/dev/null
SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH
help() {
cat <<EOF
A simply file copyright menagment system
USAGE:
stamp [OPTIONS] FILE_OR_DIRECTORY
OPTIONS:
--help | -h
Display this help and exit.
--version | -v
Display version and copyright information and exit.
--license | -l L
Specify a license.
ARGUMENTS:
FILE_OR_DIRECTORY := [[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.
EOF
}
reuse_run() {
root="$(git rev-parse --show-toplevel)"
if [ -e "$root/.reuse/templates/default" ]; then
reuse annotate \
--copyright "$(git config --get user.name) <$(git config --get user.email)>" \
--copyright-style string-c \
--template default \
--license "$license" "$1"
else
reuse annotate \
--copyright "$(git config --get user.name) <$(git config --get user.email)>" \
--copyright-style string-c \
--license "$license" "$1"
fi
}
for arg in "$@"; do
case "$arg" in
"--help" | "-h")
help
exit 0
;;
"--version" | "-v")
version
exit 0
;;
esac
done
while [ "$#" -gt 0 ]; do
case "$1" in
"--license" | "-l")
shift 1
license="$1"
[ "$license" ] || die "No license specified. See --help for more."
shift 1
;;
*)
file="$1"
shift 1
;;
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
# vim: ft=sh
|