code: def main(argd=None):
      
      global DEBUG, debug
  
      # The argd parameter for main() is for testing purposes only.
      argd = argd or docopt(
          USAGESTR,
          version=VERSIONSTR,
          script=SCRIPT,
          # Example usage of colr_docopt colors.
          colors={
              'header': {'fore': 'yellow'},
              'script': {'fore': 'lightblue', 'style': 'bright'},
              'version': {'fore': 'lightblue'},
          }
      )
  
      DEBUG = argd['--debug']
      # Load real debug function if available.
      if DEBUG:
          load_debug_deps()
      else:
          debug = noop
  
      if argd['--auto-disable']:
          auto_disable()
  
      if argd['--names']:
          return list_names()
      elif argd['--translate']:
          # Just translate a simple code and exit.
          try:
              print('\n'.join(
                  translate(
                      argd['CODE'] or read_stdin().split(),
                      rgb_mode=argd['--truecolor'],
                  )
              ))
          except ValueError as ex:
              print_err('Translation error: {}'.format(ex))
              return 1
          return 0
      elif argd['--listcodes']:
          # List all escape codes found in some text and exit.
          return list_known_codes(
              argd['TEXT'] or read_stdin(),
              unique=argd['--unique'],
              rgb_mode=argd['--truecolor'],
          )
  
      txt = argd['TEXT'] or read_stdin()
      fd = sys.stderr if argd['--err'] else sys.stdout
      end = '' if argd['--newline'] else '\n'
  
      if argd['--stripcodes']:
          txt = justify(strip_codes(txt), argd)
          print(txt, file=fd, end=end)
          return 0
  
      clr = get_colr(txt, argd)
  
      # Center, ljust, rjust, or not.
      clr = justify(clr, argd)
      if clr:
          print(str(clr), file=fd, end=end)
          return 0
      # Error while building Colr.
      return 1
docs: Main entry point, expects doctopt arg dict as argd.