Skip to content

Commit

Permalink
feature: add --no-color to disable colored output
Browse files Browse the repository at this point in the history
  • Loading branch information
serpi90 authored and fniephaus committed Nov 26, 2020
1 parent 9882ef4 commit e2b46d3
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 24 deletions.
47 changes: 40 additions & 7 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,35 @@ readonly ANSI_RESET="\033[0m"
readonly ANSI_CLEAR="\033[0K"

print_info() {
printf "${ANSI_BOLD}${ANSI_BLUE}%s${ANSI_RESET}\n" "$1"
if is_colorful; then
printf "${ANSI_BOLD}${ANSI_BLUE}%s${ANSI_RESET}\n" "$1"
else
echo "$1"
fi
}

print_notice() {
printf "${ANSI_BOLD}${ANSI_YELLOW}%s${ANSI_RESET}\n" "$1"
if is_colorful; then
printf "${ANSI_BOLD}${ANSI_YELLOW}%s${ANSI_RESET}\n" "$1"
else
echo "$1"
fi
}

print_success() {
printf "${ANSI_BOLD}${ANSI_GREEN}%s${ANSI_RESET}\n" "$1"
if is_colorful; then
printf "${ANSI_BOLD}${ANSI_GREEN}%s${ANSI_RESET}\n" "$1"
else
echo "$1"
fi
}

print_error() {
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\n" "$1" 1>&2
if is_colorful; then
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\n" "$1" 1>&2
else
echo "$1"
fi
}

print_error_and_exit() {
Expand All @@ -51,6 +67,7 @@ print_help() {
--headful Open vm in headful mode and do not close image.
--image Custom image for build (Squeak/Pharo).
--install Install symlink to this smalltalkCI instance.
--no-color Disable colored output
--no-tracking Disable collection of anonymous build metrics (TravisCI & AppVeyor only).
-s | --smalltalk Overwrite Smalltalk image selection.
--uninstall Remove symlink to any smalltalkCI instance.
Expand Down Expand Up @@ -93,6 +110,10 @@ print_config() {
done
}

is_colorful() {
[[ "${config_colorful:-true}" == "true" ]]
}

is_empty() {
local var=$1

Expand Down Expand Up @@ -629,7 +650,11 @@ travis_jigger() {
sleep 60
done

echo -e "\n${ANSI_BOLD}${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"$@\"${ANSI_RESET}\n"
if is_colorful; then
echo -e "\n${ANSI_BOLD}${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"$@\"${ANSI_RESET}\n"
else
echo -e "\nTimeout (${timeout} minutes) reached. Terminating \"$@\"\n"
fi
kill -9 $cmd_pid
}

Expand All @@ -644,7 +669,11 @@ fold_start() {
echo -en "travis_fold:start:${prefix}${identifier}\r${ANSI_CLEAR}"
echo -en "travis_time:start:$travis_timer_id\r${ANSI_CLEAR}"
fi
echo -e "${ANSI_BOLD}${ANSI_BLUE}${title}${ANSI_RESET}"
if is_colorful; then
echo -e "${ANSI_BOLD}${ANSI_BLUE}${title}${ANSI_RESET}"
else
echo -e "${title}"
fi
}

fold_end() {
Expand All @@ -658,6 +687,10 @@ fold_end() {
echo -en "travis_fold:end:${prefix}${identifier}\r${ANSI_CLEAR}"
else
duration=$(echo "${duration}" | awk '{printf "%.3f\n", $1/1000000000}')
printf "${ANSI_RESET}${ANSI_BLUE} > Time to run: %ss ${ANSI_RESET}\n" "${duration}"
if is_colorful; then
printf "${ANSI_RESET}${ANSI_BLUE} > Time to run: %ss${ANSI_RESET}\n" "${duration}"
else
printf " > Time to run: %ss\n" "${duration}"
fi
fi
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansi
ansiBlue
^ self escape, '[34m'
^ self isColorful
ifTrue: [ self escape, '[34m' ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansi
ansiBold
^ self escape, '[1m'
^ self isColorful
ifTrue: [ self escape, '[1m' ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansi
ansiClear
^ self escape, '[0K'
^ self isColorful
ifTrue: [ self escape, '[0K' ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansi
ansiGray
^ self escape, '[37m'
^ self isColorful
ifTrue: [ self escape, '[37m' ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansi
ansiGreen
^ self escape, '[32m'
^ self isColorful
ifTrue: [ self escape, '[32m' ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansi
ansiRed
^ self escape, '[31m'
^ self isColorful
ifTrue: [ self escape, '[31m' ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansi
ansiReset
^ self escape, '[0m'
^ self isColorful
ifTrue: [ self escape, '[0m' ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ansi
ansiYellow
^ self escape, '[33m'
^ self isColorful
ifTrue: [ self escape, '[33m' ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
helpers
isColorful
"IsColorful := nil"
^ IsColorful ifNil: [ IsColorful := (self getEnv: 'SCIII_COLORFUL') = 'true' ]
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"class" : {
"allCategoryNames" : "fn 6/21/2016 22:59",
"allPackageNames" : "fn 6/22/2016 00:43",
"ansiBlue" : "fn 9/26/2016 16:11",
"ansiBold" : "fn 9/26/2016 16:11",
"ansiClear" : "fn 9/26/2016 16:11",
"ansiGray" : "fn 9/26/2016 16:11",
"ansiGreen" : "fn 9/26/2016 16:11",
"ansiRed" : "fn 9/26/2016 16:11",
"ansiReset" : "fn 9/26/2016 16:11",
"ansiYellow" : "fn 9/26/2016 16:12",
"ansiBlue" : "fn 11/26/2020 12:21",
"ansiBold" : "fn 11/26/2020 12:21",
"ansiClear" : "fn 11/26/2020 12:21",
"ansiGray" : "fn 11/26/2020 12:21",
"ansiGreen" : "fn 11/26/2020 12:22",
"ansiRed" : "fn 11/26/2020 12:22",
"ansiReset" : "fn 11/26/2020 12:22",
"ansiYellow" : "fn 11/26/2020 12:22",
"assureDirectoryExistence:" : "smalltalkCI 9/2/2020 17:46",
"basename:" : "fn 11/20/2017 14:10",
"buildDirectory" : "fn 10/12/2016 00:03",
Expand Down Expand Up @@ -48,6 +48,7 @@
"imagePath" : "fn 9/27/2016 20:11",
"installMetacello" : "fn 1/31/2016 19:21",
"isAppVeyorBuild" : "fn 10/9/2016 21:44",
"isColorful" : "fn 11/26/2020 12:19",
"isDebug" : "fn 12/22/2016 12:44",
"isGitLabCIBuild" : "PeterUhnak 10/19/2017 12:46",
"isHeadless" : "fn 10/11/2016 21:08",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"classvars" : [
"DeprecationWarnings",
"IsColorful",
"PlatformClass",
"TravisID" ],
"commentStamp" : "",
Expand Down
4 changes: 3 additions & 1 deletion repository/SmalltalkCI-Core.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
(name 'SmalltalkCI-Core-smalltalkCI.257' message 'Change default of promptToProceed to keep image open' id '35024ec0-98d8-4551-b86e-bd59db86e080' date '4 September 2020' time '2:48:56.328475 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.256' message 'Delegate promptToProceed to promptToProceedImpl to avoid infinite recursion' id '1a4ba816-d3fb-4b4f-8654-af752fcf17e9' date '4 September 2020' time '2:48:10.934365 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.255' message 'Delegate promptToProceed to platformclass' id '9bb2347e-0b0b-4d62-93e1-16f79625f6f7' date '4 September 2020' time '2:43:45.730905 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.254' message 'Add promptToProceed to SmalltalkCI' id 'c9c0b396-e8c2-4d04-a320-8377e0c16bec' date '3 September 2020' time '12:07:21.192529 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.253' message 'Close Progressbars before prompting to proceed' id '4ceddd02-20fb-4888-bb8b-fd9e5bff8671' date '3 September 2020' time '11:34:57.661483 am' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.252' message 'Add promptToProceed helper function' id 'dc0d9a8e-b8d4-4ccc-bd41-7519db135042' date '3 September 2020' time '11:17:47.176847 am' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.251' message 'Add missing period in failAndQuit:' id 'ddfd0c64-51d6-48cb-a977-776e3b081e93' date '27 August 2020' time '3:26:18.498778 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.250' message 'Use correct platformClass for self calls in failAndQuit:' id 'b316831d-b0cb-4690-a465-2ae18d4747e0' date '26 August 2020' time '2:35:45.846989 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.249' message 'Add reference to image folder in saveAndQuit:' id '7d3e7080-d695-4a63-932d-38cf21e4a9ec' date '26 August 2020' time '2:32:45.92929 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.248' message 'Add failAndQuit: helper' id '922f314e-28b7-4738-90a4-e6844dc35ea0' date '26 August 2020' time '2:16:40.79477 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.247' message 'Fix unit in fold:on:block:' id '2d7dd736-99ac-4f39-936f-20828deba5c6' date '25 August 2020' time '1:06:34.562412 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-fn.246' message 'Do nothing by default in SCITestRunner>>serializeError:of: (#440).' id '5d923b61-521c-4d39-aab6-65bd3631e33f' date '26 September 2019' time '3:27:58.152573 pm' author 'fn' ancestors ((name 'SmalltalkCI-Core-EstebanLorenzano.245' message 'extend ignoreImage api to react to MetacelloIgnorePackageLoaded.This will force the load of a package already in image even if is in the ancestor list.' id 'a71d4650-a333-0d00-9a56-d9c206468e0a' date '2 October 2018' time '6:40:16.696915 pm' author 'EstebanLorenzano' ancestors ((name 'SmalltalkCI-Core-EstebanLorenzano.244' message 'expose #ignoreImage metacello api' id 'aa61a3ae-a133-0d00-be56-b23706db7c03' date '2 October 2018' time '4:43:29.93288 pm' author 'EstebanLorenzano' ancestors ((name 'SmalltalkCI-Core-fn.243' message 'Use classVariableNames instead of instanceVariableNames on class side (fixes #395).' id '60d9f141-3bd4-4585-b65e-14af44c01c81' date '2 October 2018' time '9:18:40.024 am' author 'fn' ancestors ((name 'SmalltalkCI-Core-fn.242' message 'Merge commit (240+241); apply #onConflict/#onUpgrade only when values are not nil.' id 'f287589a-5208-4534-b637-9cca010ca578' date '2 October 2018' time '8:51:04.357 am' author 'fn' ancestors ((name 'SmalltalkCI-Core-JohanBrichau.241' message 'Change option disableSerializeError to serializeError' id '7256b7b0-0a32-0d00-8794-11e9012935e3' date '12 September 2018' time '11:09:53.105902 am' author 'JohanBrichau' ancestors ((name 'SmalltalkCI-Core-JohanBrichau.240' message 'Change option disableSerializeError to serializeError' id 'd39938a7-0a32-0d00-8792-5dcd012935e3' date '12 September 2018' time '11:07:13.80521 am' author 'JohanBrichau' ancestors ((name 'SmalltalkCI-Core-fn.239' message 'Update Metacello repository URL.' id '10ec3dcf-d1fe-4fc3-9193-8affb4be053b' date '7 December 2017' time '11:34:47.321 am' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())(name 'SmalltalkCI-Core-EstebanLorenzano.240' message 'add #onConflict:/#onUpgrade: metacello logic' id 'be7e2fe1-4f33-0d00-9fd9-e2a50f2ac847' date '28 September 2018' time '3:07:50.658062 pm' author 'EstebanLorenzano' ancestors ((id '10ec3dcf-d1fe-4fc3-9193-8affb4be053b')) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
(name 'SmalltalkCI-Core-fn.258' message 'Introduce SmalltalkCI class>>#isColorful' id '9790a636-679f-4585-86ce-a2db1457f78d' date '26 November 2020' time '12:23:37.055938 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.257' message 'Change default of promptToProceed to keep image open' id '35024ec0-98d8-4551-b86e-bd59db86e080' date '4 September 2020' time '2:48:56.328475 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.256' message 'Delegate promptToProceed to promptToProceedImpl to avoid infinite recursion' id '1a4ba816-d3fb-4b4f-8654-af752fcf17e9' date '4 September 2020' time '2:48:10.934365 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.255' message 'Delegate promptToProceed to platformclass' id '9bb2347e-0b0b-4d62-93e1-16f79625f6f7' date '4 September 2020' time '2:43:45.730905 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.254' message 'Add promptToProceed to SmalltalkCI' id 'c9c0b396-e8c2-4d04-a320-8377e0c16bec' date '3 September 2020' time '12:07:21.192529 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.253' message 'Close Progressbars before prompting to proceed' id '4ceddd02-20fb-4888-bb8b-fd9e5bff8671' date '3 September 2020' time '11:34:57.661483 am' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.252' message 'Add promptToProceed helper function' id 'dc0d9a8e-b8d4-4ccc-bd41-7519db135042' date '3 September 2020' time '11:17:47.176847 am' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.251' message 'Add missing period in failAndQuit:' id 'ddfd0c64-51d6-48cb-a977-776e3b081e93' date '27 August 2020' time '3:26:18.498778 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.250' message 'Use correct platformClass for self calls in failAndQuit:' id 'b316831d-b0cb-4690-a465-2ae18d4747e0' date '26 August 2020' time '2:35:45.846989 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.249' message 'Add reference to image folder in saveAndQuit:' id '7d3e7080-d695-4a63-932d-38cf21e4a9ec' date '26 August 2020' time '2:32:45.92929 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.248' message 'Add failAndQuit: helper' id '922f314e-28b7-4738-90a4-e6844dc35ea0' date '26 August 2020' time '2:16:40.79477 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-smalltalkCI.247' message 'Fix unit in fold:on:block:' id '2d7dd736-99ac-4f39-936f-20828deba5c6' date '25 August 2020' time '1:06:34.562412 pm' author 'smalltalkCI' ancestors ((name 'SmalltalkCI-Core-fn.246' message 'Do nothing by default in SCITestRunner>>serializeError:of: (#440).' id '5d923b61-521c-4d39-aab6-65bd3631e33f' date '26 September 2019' time '3:27:58.152573 pm' author 'fn' ancestors ((name 'SmalltalkCI-Core-EstebanLorenzano.245' message 'extend ignoreImage api to react to MetacelloIgnorePackageLoaded.

This will force the load of a package already in image even if is in the ancestor list.' id 'a71d4650-a333-0d00-9a56-d9c206468e0a' date '2 October 2018' time '6:40:16.696915 pm' author 'EstebanLorenzano' ancestors ((name 'SmalltalkCI-Core-EstebanLorenzano.244' message 'expose #ignoreImage metacello api' id 'aa61a3ae-a133-0d00-be56-b23706db7c03' date '2 October 2018' time '4:43:29.93288 pm' author 'EstebanLorenzano' ancestors ((name 'SmalltalkCI-Core-fn.243' message 'Use classVariableNames instead of instanceVariableNames on class side (fixes #395).' id '60d9f141-3bd4-4585-b65e-14af44c01c81' date '2 October 2018' time '9:18:40.024 am' author 'fn' ancestors ((name 'SmalltalkCI-Core-fn.242' message 'Merge commit (240+241); apply #onConflict/#onUpgrade only when values are not nil.' id 'f287589a-5208-4534-b637-9cca010ca578' date '2 October 2018' time '8:51:04.357 am' author 'fn' ancestors ((name 'SmalltalkCI-Core-JohanBrichau.241' message 'Change option disableSerializeError to serializeError' id '7256b7b0-0a32-0d00-8794-11e9012935e3' date '12 September 2018' time '11:09:53.105902 am' author 'JohanBrichau' ancestors ((name 'SmalltalkCI-Core-JohanBrichau.240' message 'Change option disableSerializeError to serializeError' id 'd39938a7-0a32-0d00-8792-5dcd012935e3' date '12 September 2018' time '11:07:13.80521 am' author 'JohanBrichau' ancestors ((name 'SmalltalkCI-Core-fn.239' message 'Update Metacello repository URL.' id '10ec3dcf-d1fe-4fc3-9193-8affb4be053b' date '7 December 2017' time '11:34:47.321 am' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())(name 'SmalltalkCI-Core-EstebanLorenzano.240' message 'add #onConflict:/#onUpgrade: metacello logic' id 'be7e2fe1-4f33-0d00-9fd9-e2a50f2ac847' date '28 September 2018' time '3:07:50.658062 pm' author 'EstebanLorenzano' ancestors ((id '10ec3dcf-d1fe-4fc3-9193-8affb4be053b')) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
6 changes: 6 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ parse_options() {
fi
shift 2
;;
--no-color)
config_colorful="false"
shift
;;
--no-tracking)
config_tracking="false"
shift
Expand Down Expand Up @@ -370,6 +374,7 @@ prepare_environment() {
add_env_vars() {
export SCIII_SMALLTALK="${config_smalltalk}"
export SCIII_BUILD="$(resolve_path "${SMALLTALK_CI_BUILD}")"
export SCIII_COLORFUL="${config_colorful}"
export SCIII_DEBUG="${config_debug}"
}

Expand Down Expand Up @@ -488,6 +493,7 @@ main() {
local config_debug="false"
local config_headless="true"
local config_image=""
local config_colorful="true"
local config_tracking="true"
local config_verbose="false"
local config_vm=""
Expand Down

0 comments on commit e2b46d3

Please sign in to comment.