From bd5c5df9da3e9d35f8d9979534188976d6c9398e Mon Sep 17 00:00:00 2001 From: jsseidel Date: Fri, 1 Nov 2019 19:21:36 +0000 Subject: [PATCH] Added argument to suppress coloring in output. Fix for issue #26 --- bin/mktechdocs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/bin/mktechdocs b/bin/mktechdocs index ad0b4dd..aaadef2 100755 --- a/bin/mktechdocs +++ b/bin/mktechdocs @@ -72,7 +72,11 @@ function clog { ;; esac - echo -e "${COL}${TYPEOUT}${NC}$MSG" + if [[ "$NO_COLOR_OUTPUT" == "0" ]] ; then + echo -e "${COL}${TYPEOUT}${NC}$MSG" + else + echo -e "${TYPEOUT}$MSG" + fi } # @@ -215,21 +219,40 @@ function cleanup { # MAIN ############################################################################# +# Check for if we need to turn off colors in our output +NO_COLOR_OUTPUT=0 +if [[ "$1" == "--no-color-output" || "$1" == "-n" ]] ; then + NO_COLOR_OUTPUT=1 + shift +fi + # We need a project directory and configuration file CFG=$1 PROJECT_DIR=$2 if [[ "$CFG" == "help" || "$CFG" == "--help" || "$CFG" == "-?" || "$CFG" == "?" ]] ; then - echo "Usage: mtechdocs [help|clean|init]" + echo "Usage: mtechdocs [-n|--no-color-output] [help|clean|init]" + echo " The optional -n or --no-color-output argument suppresses coloring" + echo " in output to the terminal, useful for jenkins builds or other places" + echo " where bash coloring information is not interpreted." + echo "" echo " help : Display this help message" echo " clean: Remove temporary build files" echo " init : Create a new MkTechDocs project in the current directory" echo - echo "Usage: mtechdocs" + echo "Usage: mtechdocs [-n|--no-color-output]" + echo " The optional -n or --no-color-output argument suppresses coloring" + echo " in output to the terminal, useful for jenkins builds or other places" + echo " where bash coloring information is not interpreted." + echo "" echo " Builds the MkTechDocs project in the current directory. Assumes" echo " that a mktechdocs.conf file and master.md file are present." echo - echo "Usage: mtechdocs " + echo "Usage: mtechdocs [-n|--no-color-output] " + echo " The optional -n or --no-color-output argument suppresses coloring" + echo " in output to the terminal, useful for jenkins builds or other places" + echo " where bash coloring information is not interpreted." + echo "" echo " Builds the MkTechDocs project in the given directory using the" echo " given configuration." exit 0