def supportsColour:
  $ENV["JQ_SUPPORTS_COLOR"] == "1" or $ENV["JQ_SUPPORTS_COLOUR"] == "1" ;

def CSR:
  "\u001b[";

def resetColours: 
  CSR + "0m";

def colourText($colourCode):
  . as $text |
  if supportsColour | not then
    $text
  else
    CSR + ($colourCode | tostring) + "m" + $text + resetColours
  end;

def colourText($colourCode; $mode):
  . as $text |
  if supportsColour | not then
    $text
  else
    CSR + ($mode | tostring)  + ";" + ($colourCode | tostring) + "m" + $text + resetColours
  end;