1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-09-25 12:40:44 +00:00

test-in-docker: add dry-run mode

This commit is contained in:
Christian Höltje 2018-06-27 11:25:12 -04:00
parent 89863209fc
commit 83abdf742c

View file

@ -72,6 +72,14 @@ check_for_known_issues() {
fi fi
} }
cmd() {
if (( dry_run )); then
echo "${(@q)*}" 1>&2
else
"${(@)*}"
fi
}
build_and_run() { build_and_run() {
local version="$1" local version="$1"
local framework="$2" local framework="$2"
@ -82,14 +90,14 @@ build_and_run() {
print -P "%F{green}Preparing containers...%f" print -P "%F{green}Preparing containers...%f"
echo -n "p9k:base-${version}: " echo -n "p9k:base-${version}: "
docker build \ cmd docker build \
--quiet \ --quiet \
--tag "p9k:base-${version}" \ --tag "p9k:base-${version}" \
--file "docker/base-${version}/Dockerfile" \ --file "docker/base-${version}/Dockerfile" \
. .
echo -n "p9k:${version}-${framework}: " echo -n "p9k:${version}-${framework}: "
docker build \ cmd docker build \
--quiet \ --quiet \
--build-arg="base=base-${version}" \ --build-arg="base=base-${version}" \
--tag "p9k:${version}-${framework}" \ --tag "p9k:${version}-${framework}" \
@ -97,7 +105,7 @@ build_and_run() {
. .
print -P "%F{green}Starting ${name} container...%f" print -P "%F{green}Starting ${name} container...%f"
exec docker run \ cmd docker run \
--rm \ --rm \
--interactive \ --interactive \
--tty \ --tty \
@ -112,9 +120,10 @@ show_help() {
echo echo
echo "Loads up a docker image with powershell9k configured in <framework>" echo "Loads up a docker image with powershell9k configured in <framework>"
echo echo
echo " --frameworks Lists all available frameworks, newline separated." echo " -f --frameworks Lists all available frameworks, newline separated."
echo " --versions Lists all available ZSH versions, newline separated." echo " -v --versions Lists all available ZSH versions, newline separated."
echo " --zsh VER Uses ZSH with version VER." echo " -z --zsh VER Uses ZSH with version VER."
echo " -n --dry-run Just prints the docker commands that would be run."
echo " --help You're soaking in it." echo " --help You're soaking in it."
echo echo
echo "ZSH versions:" echo "ZSH versions:"
@ -137,6 +146,7 @@ fi
# Parse flags and such. # Parse flags and such.
use_version=$default_version use_version=$default_version
use_framework= use_framework=
dry_run=0
while (( $# > 0 )); do while (( $# > 0 )); do
case "$1" in case "$1" in
-f | --frameworks ) -f | --frameworks )
@ -156,6 +166,7 @@ while (( $# > 0 )); do
err "No such ZSH version '${1}'" err "No such ZSH version '${1}'"
fi fi
;; ;;
-n | --dry-run ) dry_run=1 ;;
-h | --help ) -h | --help )
show_help show_help
exit exit
@ -181,7 +192,7 @@ while (( $# > 0 )); do
shift shift
done done
typeset -r use_version use_framework typeset -r use_version use_framework dry_run
build_and_run "$use_version" "$use_framework" build_and_run "$use_version" "$use_framework"