1 |
#!/bin/sh |
2 |
# $TheSupernovaDuo: git-send-paste,v 0.1.0 2023/5/27 23:35:57 yakumo_izuru Exp $ |
3 |
# |
4 |
# Send git patches to a pastebin endpoint using nc(1) |
5 |
# https://git.kyoko-project.wer.ee/koizumi.aoi/git-crap |
6 |
|
7 |
usage() { |
8 |
printf "Usage: %s --diff=<diff> --paste=<paste>\n" "${0##/*}" |
9 |
} |
10 |
|
11 |
for arg; do |
12 |
case $arg in |
13 |
-h) usage ;; |
14 |
--diff=*) diff=${arg#*=} ;; |
15 |
--paste=*) paste=${arg#*=} ;; |
16 |
*-*) printf "Unknown option: %s\n" "$arg" ;; |
17 |
*=*) export "${arg:?}" ;; |
18 |
*) printf "Unknown argument: %s\n" "$arg" ;; |
19 |
esac |
20 |
done |
21 |
|
22 |
if [ -z $diff && -z $paste ]; then |
23 |
usage |
24 |
exit 1 |
25 |
else |
26 |
printf "Sending patch file %s to endpoint %s\n" "${diff}" "${paste}" |
27 |
cat $diff | nc $paste 9999 |
28 |
fi |