diff options
author | EuAndreh <eu@euandre.org> | 2021-06-26 19:03:51 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-06-26 21:32:31 -0300 |
commit | bd919c08110bec0e42a4b02ba0f01814675f2fb9 (patch) | |
tree | 4e343a5c2e162f93165db9d6c7470c91a53093e2 /aux/workflow/dist.sh | |
parent | aux/workflow/assert-manpages.sh: Use getopts for arguments (diff) | |
download | git-permalink-bd919c08110bec0e42a4b02ba0f01814675f2fb9.tar.gz git-permalink-bd919c08110bec0e42a4b02ba0f01814675f2fb9.tar.xz |
aux/workflow/dist.sh: Use getopts for arguments
Diffstat (limited to 'aux/workflow/dist.sh')
-rwxr-xr-x | aux/workflow/dist.sh | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/aux/workflow/dist.sh b/aux/workflow/dist.sh index ed61ee5..ab94f20 100755 --- a/aux/workflow/dist.sh +++ b/aux/workflow/dist.sh @@ -1,19 +1,53 @@ #!/bin/sh set -eu -DATE="$1" -VVERSION="v$2" -PROJECT_UC="$3" -PROJECT="$4" -MAILING_LIST="$5" +while getopts 'd:V:n:N:m:' flag; do + case "$flag" in + d) + DATE="$OPTARG" + ;; + V) + VVERSION="v$OPTARG" + ;; + n) + PROJECT="$OPTARG" + ;; + N) + PROJECT_UC="$OPTARG" + ;; + m) + MAILING_LIST="$OPTARG" + ;; + *) + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +assert_arg() { + if [ -z "$1" ]; then + echo "Missing $2" >&2 + exit 2 + fi +} + +assert_arg "${DATE:-}" '-d DATE' +assert_arg "${VVERSION:-}" '-V VERSION' +assert_arg "${PROJECT:-}" '-n PROJECT' +assert_arg "${MAILING_LIST:-}" '-m MAILING_LIST' + +if [ -z "${PROJECT_UC:-}" ]; then + PROJECT_UC="$PROJECT" +fi if git show "$VVERSION" 1>/dev/null 2>/dev/null; then echo "Version '$VVERSION' already exists." >&2 exit 1 fi -sh aux/workflow/assert-changelog.sh "$PROJECT_UC" "$PROJECT" "$VVERSION" -sh aux/workflow/assert-readme.sh "$PROJECT" "$MAILING_LIST" "$VVERSION" +sh aux/workflow/assert-changelog.sh -N "$PROJECT_UC" -n "$PROJECT" "$VVERSION" +sh aux/workflow/assert-readme.sh -n "$PROJECT" -m "$MAILING_LIST" "$VVERSION" if [ "$DATE" != "$(git log -1 --format=%cd --date=short HEAD)" ]; then echo "Date '$DATE' is not up-to-date." >&2 |