-
Notifications
You must be signed in to change notification settings - Fork 2
/
git-generate-license
executable file
·132 lines (116 loc) · 3.75 KB
/
git-generate-license
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env sh
version() {
echo "git license generator v1.0"
}
licenselist() {
echo "1-) Apache License 2.0"
echo "2-) GNU General Public License v3.0"
echo "3-) MIT License"
echo "4-) BSD 2-Clause \"Simplified\" License"
echo "5-) BSD 3-Clause \"New\" or \"Revised\" License"
echo "6-) Eclipse Public License 2.0"
echo "7-) GNU Affero General Public License v3.0"
echo "8-) GNU General Public License v2.0"
echo "9-) GNU Lesser General Public License v2.1"
echo "10-) GNU Lesser General Public License v3.0"
echo "11-) Mozilla Public License 2.0"
echo "12-) The Unlicense"
echo "13-) Do What The Fuck You Want To Public License"
}
usage() {
echo "usage: git generate-license <license-name>"
echo
echo "Available commands are:"
echo "git generate-license -l | --list -- Print out all available licenses"
echo "git generate-license -s | --select -- License selection"
echo "git generate-license -h | --help"
}
selectlicense() {
clear
licenselist
echo "Exit: 0"
echo
echo "Select a license. Please input a number: "
echo
read selectedlicense
clear
echo
licenselist
echo
echo > "$(pwd)/LICENSE.md"
case $selectedlicense in
"1")
cat "/usr/local/bin/apache-v2.md" >> "$(pwd)/LICENSE.md"
echo "Apache License 2.0 Generated"; exit 0
;;
"2")
cat "/usr/local/bin/gpl-v3.md" >> "$(pwd)/LICENSE.md"
echo "GNU General Public License v3.0 Generated"; exit 0
;;
"3")
cat "/usr/local/bin/mit.md" >> "$(pwd)/LICENSE.md"
echo "MIT License Generated"; exit 0
;;
"4")
cat "/usr/local/bin/bsd-v2-clause.md" >> "$(pwd)/LICENSE.md"
echo "BSD 2-Clause \"Simplified\" License Generated"; exit 0
;;
"5")
cat "/usr/local/bin/bsd-v3-clause.md" >> "$(pwd)/LICENSE.md"
echo "BSD 3-Clause \"New\" or \"Revised\" License"; exit 0
;;
"6")
cat "/usr/local/bin/epl-v2.md" >> "$(pwd)/LICENSE.md"
echo "Eclipse Public License 2.0 Generated"; exit 0
;;
"7")
cat "/usr/local/bin/agpl-v3.md" >> "$(pwd)/LICENSE.md"
echo "GNU Affero General Public License v3.0 Generated"; exit 0
;;
"8")
cat "/usr/local/bin/gpl-v2.md" >> "$(pwd)/LICENSE.md"
echo "GNU General Public License v2.0 Generated"; exit 0
;;
"9")
cat "/usr/local/bin/lgpl-v2-1.md" >> "$(pwd)/LICENSE.md"
echo "GNU Lesser General Public License v2.1 Generated"; exit 0
;;
"10")
cat "/usr/local/bin/lgpl-v3.md" >> "$(pwd)/LICENSE.md"
echo "GNU Lesser General Public License v3.0 Generated"; exit 0
;;
"11")
cat "/usr/local/bin/mpl-v2.md" >> "$(pwd)/LICENSE.md"
echo "Mozilla Public License 2.0 Generated"; exit 0
;;
"12")
cat "/usr/local/bin/unlicense.md" >> "$(pwd)/LICENSE.md"
echo "The Unlicense Generated"; exit 0
;;
"13")
cat "/usr/local/bin/wtfpl.md" >> "$(pwd)/LICENSE.md"
echo "Do What The Fuck You Want To Public License Generated"; exit 0
;;
esac
}
main() {
if [ "$#" -lt 1 ]; then
usage; exit 1
fi
local subcommand="$1"; shift
case $subcommand in
"-h"|"--help")
usage; exit 0
;;
"-v"|"--version")
version; exit 0
;;
"-l"|"--list")
licenselist; exit 0
;;
"-s"|"--select")
selectlicense; exit 0
;;
esac
}
main "$@"