remove getopt and support short options too
This commit is contained in:
parent
867bd32820
commit
f4488c930e
40
migrate.sh
40
migrate.sh
@ -22,53 +22,47 @@ create_repo() {
|
|||||||
[[ "$repoid" != "null" ]] && sleep 5 || true
|
[[ "$repoid" != "null" ]] && sleep 5 || true
|
||||||
}
|
}
|
||||||
|
|
||||||
ARGUMENT_LIST=(
|
|
||||||
"url:"
|
|
||||||
"token:"
|
|
||||||
"admin::"
|
|
||||||
"password::"
|
|
||||||
"pushurl::"
|
|
||||||
)
|
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
: ${GITEA_ADMIN_USERNAME:=$USER}
|
: ${GITEA_ADMIN_USERNAME:=$USER}
|
||||||
: ${GITEA_ADMIN_PASSWORD:=}
|
: ${GITEA_ADMIN_PASSWORD:=}
|
||||||
# example ssh://git@gitea.example.com:3022
|
# example ssh://git@gitea.example.com:3022
|
||||||
: ${GITEA_SERVER_PUSH_URL:=}
|
: ${GITEA_SERVER_PUSH_URL:=}
|
||||||
|
|
||||||
opts=$(
|
ARGS=()
|
||||||
getopt \
|
|
||||||
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
|
|
||||||
--name "$(basename "$0")" \
|
|
||||||
--options "" \
|
|
||||||
-- "$@"
|
|
||||||
)
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--url)
|
--url | -u)
|
||||||
GITEA_SERVER_URL="$2"
|
GITEA_SERVER_URL="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--token)
|
--token | -t)
|
||||||
GITEA_ADMIN_TOKEN="$2"
|
GITEA_ADMIN_TOKEN="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--admin)
|
--admin | -a)
|
||||||
GITEA_ADMIN_USERNAME="$2"
|
GITEA_ADMIN_USERNAME="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--password)
|
--password | -p)
|
||||||
GITEA_ADMIN_PASSWORD="$2"
|
GITEA_ADMIN_PASSWORD="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--pushurl)
|
--pushurl | -s)
|
||||||
GITEA_SERVER_PUSH_URL="$2"
|
GITEA_SERVER_PUSH_URL="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
*)
|
--)
|
||||||
|
shift 1
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
-*)
|
||||||
|
echo "unknown argument: $1" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ARGS+=("$1")
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -84,7 +78,7 @@ GITEA_SERVER_API_URL="${GITEA_SERVER_URL}/api/v1"
|
|||||||
# /path/to/repo ( use name from path, no org )
|
# /path/to/repo ( use name from path, no org )
|
||||||
|
|
||||||
# init repos
|
# init repos
|
||||||
for repo in "$@"; do
|
for repo in "${ARGS[@]}"; do
|
||||||
repoPath="$(echo "$repo" | cut -d ':' -f1 | tr -d '[:space:]')"
|
repoPath="$(echo "$repo" | cut -d ':' -f1 | tr -d '[:space:]')"
|
||||||
repoOrg="$(echo "$repo" | cut -d ':' -f2 | tr -d '[:space:]')"
|
repoOrg="$(echo "$repo" | cut -d ':' -f2 | tr -d '[:space:]')"
|
||||||
repoName="$(echo "$repo" | cut -d ':' -f3 | tr -d '[:space:]')"
|
repoName="$(echo "$repo" | cut -d ':' -f3 | tr -d '[:space:]')"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user