aboutsummaryrefslogtreecommitdiff
path: root/aux
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-26 19:07:35 -0300
committerEuAndreh <eu@euandre.org>2021-06-26 21:32:31 -0300
commitb599cb618937e1a08091b57d9359263eb101baeb (patch)
tree209c227bc65b4340703b4af31d304cb499612782 /aux
parentaux/workflow/dist.sh: Use getopts for arguments (diff)
downloadgit-permalink-b599cb618937e1a08091b57d9359263eb101baeb.tar.gz
git-permalink-b599cb618937e1a08091b57d9359263eb101baeb.tar.xz
aux/workflow/public.sh: Use getopts for arguments
Diffstat (limited to 'aux')
-rwxr-xr-xaux/workflow/public.sh39
1 files changed, 35 insertions, 4 deletions
diff --git a/aux/workflow/public.sh b/aux/workflow/public.sh
index 7433595..50417ac 100755
--- a/aux/workflow/public.sh
+++ b/aux/workflow/public.sh
@@ -1,10 +1,41 @@
#!/bin/sh
set -eu
-PROJECT_UC="$1"
-PROJECT="$2"
-MAILING_LIST="$3"
-OUTDIR="$4"
+while getopts 'n:N:m:o:' flag; do
+ case "$flag" in
+ n)
+ PROJECT="$OPTARG"
+ ;;
+ N)
+ PROJECT_UC="$OPTARG"
+ ;;
+ m)
+ MAILING_LIST="$OPTARG"
+ ;;
+ o)
+ OUTDIR="$OPTARG"
+ ;;
+ *)
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+assert_arg() {
+ if [ -z "$1" ]; then
+ echo "Missing $2" >&2
+ exit 2
+ fi
+}
+
+assert_arg "${PROJECT:-}" '-n PROJECT'
+assert_arg "${MAILING_LIST:-}" '-m MAILING_LIST'
+assert_arg "${OUTDIR:-}" '-o OUTDIR'
+
+if [ -z "${PROJECT_UC:-}" ]; then
+ PROJECT_UC="$PROJECT"
+fi
mkdir -p "$OUTDIR"