git-crap/git-send-paste

29 行
688 B
Bash

#!/bin/sh
# $TheSupernovaDuo: git-send-paste,v 0.1.0 2023/5/27 23:35:57 yakumo_izuru Exp $
#
# Send git patches to a pastebin endpoint using nc(1)
# https://git.kyoko-project.wer.ee/koizumi.aoi/git-crap
usage() {
printf "Usage: %s --diff=<diff> --paste=<paste>\n" "${0##/*}"
}
for arg; do
case $arg in
-h) usage ;;
--diff=*) diff=${arg#*=} ;;
--paste=*) paste=${arg#*=} ;;
*-*) printf "Unknown option: %s\n" "$arg" ;;
*=*) export "${arg:?}" ;;
*) printf "Unknown argument: %s\n" "$arg" ;;
esac
done
if [ -z $diff && -z $paste ]; then
usage
exit 1
else
printf "Sending patch file %s to endpoint %s\n" "${diff}" "${paste}"
cat $diff | nc $paste 9999
fi