From ddbf884cb5c4339cc2fa35cac39c62f2a44ad1aa Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 9 Jan 2024 10:50:34 +0900 Subject: [PATCH] dev: add ability to pass --docker, --podman, or --native to update.sh passing more than one of these flags is not expected --- neko/update/{docker.sh => container.sh} | 0 update.sh | 46 +++++++++++++++---------- 2 files changed, 28 insertions(+), 18 deletions(-) rename neko/update/{docker.sh => container.sh} (100%) diff --git a/neko/update/docker.sh b/neko/update/container.sh similarity index 100% rename from neko/update/docker.sh rename to neko/update/container.sh diff --git a/update.sh b/update.sh index 3cd623b45..e14f6210b 100755 --- a/update.sh +++ b/update.sh @@ -69,25 +69,35 @@ for message in $(find neko/messages -type f ! -name '*.resolved' -print | sort); fi done -say 'Do you use Docker or Podman?' -printf 'd: Docker, p: Podman, n: No [d/p/N] > ' -read -r resp +docker_update() { + ./neko/update/container.sh 'docker' "$@" +} +podman_update() { + ./neko/update/container.sh 'podman' "$@" +} +native_update() { + ./neko/update/native.sh "$@" +} -case "${resp}" in - [Dd]) - ./neko/update/docker.sh 'docker' "$@" - ;; - [Pp]) - ./neko/update/docker.sh 'podman' "$@" - ;; - [Yy]|[Yy][Ee][Ss]) - sadsay "Watch out! ${resp} is not a valid answer." >&2 - exit 1 - ;; - *) - ./neko/update/native.sh "$@" - ;; -esac +if contains '--docker' "$@"; then docker_update "$@" +elif contains '--podman' "$@"; then podman_update "$@" +elif contains '--native' "$@"; then native_update "$@" + +else + say 'Do you use Docker or Podman?' + printf 'd: Docker, p: Podman, n: No [d/p/N] > ' + read -r resp + + case "${resp}" in + [Yy]|[Yy][Ee][Ss]) + sadsay "Watch out! ${resp} is not a valid answer." >&2 + exit 1 + ;; + [Dd]) docker_update "$@" ;; + [Pp]) podman_update "$@" ;; + *) native_update "$@" ;; + esac +fi # Done say 'Enjoy your sabakan life~'