mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-06-16 16:58:08 +02:00
Improve script/mirror
argument handling
Now supports `-h|--help`.
This commit is contained in:
parent
3add5c4637
commit
95b32accd6
1 changed files with 21 additions and 5 deletions
|
@ -1,12 +1,15 @@
|
|||
#!/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?}"
|
||||
shift 1
|
||||
"$cmd" "$@"
|
||||
cmd="$1"
|
||||
|
||||
case "$cmd" in
|
||||
update | verify | stats )
|
||||
shift 1
|
||||
"$cmd" "$@"
|
||||
;;
|
||||
-h | --help )
|
||||
help_text
|
||||
exit 0
|
||||
;;
|
||||
* )
|
||||
help_text >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue