Skip to content

Commit 199c378

Browse files
author
Spencer Seidel
authored
Merge pull request #32 from att/jsseidel-feature-no-color-log-output
Added argument to suppress coloring in output. Fix for issue #26
2 parents 734f76a + bd5c5df commit 199c378

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

bin/mktechdocs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ function clog {
7272
;;
7373
esac
7474

75-
echo -e "${COL}${TYPEOUT}${NC}$MSG"
75+
if [[ "$NO_COLOR_OUTPUT" == "0" ]] ; then
76+
echo -e "${COL}${TYPEOUT}${NC}$MSG"
77+
else
78+
echo -e "${TYPEOUT}$MSG"
79+
fi
7680
}
7781

7882
#
@@ -215,21 +219,40 @@ function cleanup {
215219
# MAIN
216220
#############################################################################
217221

222+
# Check for if we need to turn off colors in our output
223+
NO_COLOR_OUTPUT=0
224+
if [[ "$1" == "--no-color-output" || "$1" == "-n" ]] ; then
225+
NO_COLOR_OUTPUT=1
226+
shift
227+
fi
228+
218229
# We need a project directory and configuration file
219230
CFG=$1
220231
PROJECT_DIR=$2
221232

222233
if [[ "$CFG" == "help" || "$CFG" == "--help" || "$CFG" == "-?" || "$CFG" == "?" ]] ; then
223-
echo "Usage: mtechdocs [help|clean|init]"
234+
echo "Usage: mtechdocs [-n|--no-color-output] [help|clean|init]"
235+
echo " The optional -n or --no-color-output argument suppresses coloring"
236+
echo " in output to the terminal, useful for jenkins builds or other places"
237+
echo " where bash coloring information is not interpreted."
238+
echo ""
224239
echo " help : Display this help message"
225240
echo " clean: Remove temporary build files"
226241
echo " init : Create a new MkTechDocs project in the current directory"
227242
echo
228-
echo "Usage: mtechdocs"
243+
echo "Usage: mtechdocs [-n|--no-color-output]"
244+
echo " The optional -n or --no-color-output argument suppresses coloring"
245+
echo " in output to the terminal, useful for jenkins builds or other places"
246+
echo " where bash coloring information is not interpreted."
247+
echo ""
229248
echo " Builds the MkTechDocs project in the current directory. Assumes"
230249
echo " that a mktechdocs.conf file and master.md file are present."
231250
echo
232-
echo "Usage: mtechdocs <config> <directory>"
251+
echo "Usage: mtechdocs [-n|--no-color-output] <config> <directory>"
252+
echo " The optional -n or --no-color-output argument suppresses coloring"
253+
echo " in output to the terminal, useful for jenkins builds or other places"
254+
echo " where bash coloring information is not interpreted."
255+
echo ""
233256
echo " Builds the MkTechDocs project in the given directory using the"
234257
echo " given configuration."
235258
exit 0

0 commit comments

Comments
 (0)