Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Improved colours #227
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasdille committed Jan 27, 2022
1 parent c55f7e2 commit 8feaa56
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions docker-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -402,44 +402,59 @@ function umoci_matches_version() { is_executable "${TARGET}
function yq_matches_version() { is_executable "${TARGET}/bin/yq" && test "$(${TARGET}/bin/yq --version | cut -d' ' -f4)" == "${YQ_VERSION}"; }
function ytt_matches_version() { is_executable "${TARGET}/bin/ytt" && test "$(${TARGET}/bin/ytt version | cut -d' ' -f3)" == "${YTT_VERSION}"; }

echo "docker-setup includes ${#tools[*]} tools:"
echo -e "docker-setup includes ${#tools[*]} tools (${GREEN}done${RESET}, ${YELLOW}planned${RESET}, ${RED}ignored${RESET}):"
declare -A tool_version
declare -a tool_install
declare -A tool_color
declare -A tool_sign
declare -a tool_outdated
check_only_exit_code=0
line_length=0
for tool in "${tools[@]}"; do
VAR_NAME="${tool^^}_VERSION"
VERSION="${VAR_NAME//-/_}"
tool_version[${tool}]="${!VERSION}"

if ! ${NO_DEPS}; then
if test -n "${tool_deps[${tool}]}"; then
for dep in $(echo "${tool_deps[${tool}]}" | tr ',' ' '); do
if ! printf "%s\n" "${tool_install[@]}" | grep -q "^${dep}$"; then
tool_install+=("${dep}")
fi
done
fi
fi

if ${REINSTALL} \
|| ( ${ONLY} && printf "%s\n" "${requested_tools[@]}" | grep -q "^${tool}$" ) \
|| ( ! ${ONLY} && ! eval "${tool//-/_}_matches_version" ); then

if ! ${NO_DEPS}; then
if test -n "${tool_deps[${tool}]}"; then
for dep in $(echo "${tool_deps[${tool}]}" | tr ',' ' '); do
if ! printf "%s\n" "${tool_install[@]}" | grep -q "^${dep}$"; then
tool_install+=("${dep}")
fi
done
fi
fi

tool_install+=("${tool}")
fi

done
check_only_exit_code=0
line_length=0
for tool in "${tools[@]}"; do
if ! eval "${tool//-/_}_matches_version"; then
tool_color[${tool}]="${YELLOW}"
tool_sign[${tool}]="${CROSS_MARK}"

tool_outdated+=("${tool}")
check_only_exit_code=1

if printf "%s\n" "${tool_install[@]}" | grep -q "^${tool}$"; then
tool_color[${tool}]="${YELLOW}"
tool_sign[${tool}]="${CROSS_MARK}"

else
tool_color[${tool}]="${RED}"
tool_sign[${tool}]="${CROSS_MARK}"
fi

else
tool_color[${tool}]="${GREEN}"
tool_sign[${tool}]="${CHECK_MARK}"
if printf "%s\n" "${tool_install[@]}" | grep -q "^${tool}$"; then
tool_color[${tool}]="${YELLOW}"
tool_sign[${tool}]="${CHECK_MARK}"

else
tool_color[${tool}]="${GREEN}"
tool_sign[${tool}]="${CHECK_MARK}"
fi
fi

item="${tool} ${tool_version[${tool}]} ${tool_sign[${tool}]}"
Expand Down Expand Up @@ -1968,12 +1983,6 @@ function count_sub_processes() {
}

declare -A child_pids
echo "The following tools will be installed:"
echo
for tool in "${tool_install[@]}"; do
echo -n "${tool} "
done
echo -e -n "\n\n"
if ${PLAN}; then
exit
fi
Expand Down

0 comments on commit 8feaa56

Please sign in to comment.