Commit 95b32acc authored by Mislav Marohnić's avatar Mislav Marohnić
Browse files

Improve `script/mirror` argument handling

Now supports `-h|--help`.
parent 3add5c46
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
#!/usr/bin/env bash
# Usage: script/mirror update <COMMIT-RANGE>
#        script/mirror verify <COMMIT-RANGE>
#        script/mirror stats
set -e

commit_range="${1?}"

eval "$(grep RUBY_BUILD_MIRROR_URL= ./bin/ruby-build | head -1)"

help_text() {
  sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
}

test_mirrored() {
  curl -qsSfIL "$RUBY_BUILD_MIRROR_URL/$1" >/dev/null 2>&1
}
@@ -95,6 +98,19 @@ stats() {
  echo "$confirmed/$total mirrored"
}

cmd="${1?}"
cmd="$1"

case "$cmd" in
update | verify | stats )
  shift 1
  "$cmd" "$@"
  ;;
-h | --help )
  help_text
  exit 0
  ;;
* )
  help_text >&2
  exit 1
  ;;
esac