ci: fmt/gen

This commit is contained in:
Anmol Sethi 2022-11-20 03:19:40 -08:00
parent c09064dc60
commit c74d32fce9
No known key found for this signature in database
GPG key ID: 25BC68888A99A8BA
3 changed files with 23 additions and 17 deletions

View file

@ -55,20 +55,22 @@ tput() {
should_color() { should_color() {
if [ -n "${COLOR-}" ]; then if [ -n "${COLOR-}" ]; then
if [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then if [ "$COLOR" = 0 -o "$COLOR" = false ]; then
_COLOR=0 _COLOR=
return 1 return 1
elif [ "${COLOR-}" = 1 -o "${COLOR-}" = true ]; then elif [ "$COLOR" = 1 -o "$COLOR" = true ]; then
_COLOR=1 _COLOR=1
return 0 return 0
else else
printf '$COLOR must be 0, 1, false or true but got %s' "$COLOR" >&2 printf '$COLOR must be 0, 1, false or true but got %s' "$COLOR" >&2
fi fi
fi fi
if [ -t 1 ]; then if [ -t 1 ]; then
_COLOR=1 _COLOR=1
return 0 return 0
else else
_COLOR=
return 1 return 1
fi fi
} }
@ -109,11 +111,12 @@ printfp() {(
if [ -z "${FGCOLOR-}" ]; then if [ -z "${FGCOLOR-}" ]; then
FGCOLOR="$(get_rand_color "$prefix")" FGCOLOR="$(get_rand_color "$prefix")"
fi fi
setaf "$FGCOLOR" "[$prefix]" if [ $# -eq 0 ]; then
should_color || true
if [ $# -gt 0 ]; then printf '%s' $(COLOR=${_COLOR-} setaf "$FGCOLOR" "$prefix")
printf ' ' else
printf "$@" should_color || true
printf '%s: %s\n' $(COLOR=${_COLOR-} setaf "$FGCOLOR" "$prefix") "$(printf "$@")"
fi fi
)} )}

2
ci/sub

@ -1 +1 @@
Subproject commit c5e5d53caa3241629a56b95eaf9780a68546ad61 Subproject commit 2eb7e4fa5e2457a62140ed3e95c1d75f75cb583c

View file

@ -61,20 +61,22 @@ tput() {
should_color() { should_color() {
if [ -n "${COLOR-}" ]; then if [ -n "${COLOR-}" ]; then
if [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then if [ "$COLOR" = 0 -o "$COLOR" = false ]; then
_COLOR=0 _COLOR=
return 1 return 1
elif [ "${COLOR-}" = 1 -o "${COLOR-}" = true ]; then elif [ "$COLOR" = 1 -o "$COLOR" = true ]; then
_COLOR=1 _COLOR=1
return 0 return 0
else else
printf '$COLOR must be 0, 1, false or true but got %s' "$COLOR" >&2 printf '$COLOR must be 0, 1, false or true but got %s' "$COLOR" >&2
fi fi
fi fi
if [ -t 1 ]; then if [ -t 1 ]; then
_COLOR=1 _COLOR=1
return 0 return 0
else else
_COLOR=
return 1 return 1
fi fi
} }
@ -115,11 +117,12 @@ printfp() {(
if [ -z "${FGCOLOR-}" ]; then if [ -z "${FGCOLOR-}" ]; then
FGCOLOR="$(get_rand_color "$prefix")" FGCOLOR="$(get_rand_color "$prefix")"
fi fi
setaf "$FGCOLOR" "[$prefix]" if [ $# -eq 0 ]; then
should_color || true
if [ $# -gt 0 ]; then printf '%s' $(COLOR=${_COLOR-} setaf "$FGCOLOR" "$prefix")
printf ' ' else
printf "$@" should_color || true
printf '%s: %s\n' $(COLOR=${_COLOR-} setaf "$FGCOLOR" "$prefix") "$(printf "$@")"
fi fi
)} )}