docs: def parse_colr_arg(
          s: str,
          default: Optional[Any] = None,
          rgb_mode: Optional[bool] = False) -> ColorArg:
      """ Parse a user argument into a usable fore/back color value for Colr.
          If a falsey value is passed, default is returned.
          Raises InvalidColr if the argument is unusable.
          Returns: A usable value for Colr(fore/back).
  
          This validates basic/extended color names.
          This validates the range for basic/extended values (0-255).
          This validates the length/range for rgb values (0-255, 0-255, 0-255).
  
          Arguments:
              s  : User's color value argument.
                   Example: "1", "255", "black", "25,25,25"
      """
      if not s:
          return default
  
      val = s.strip().lower()
      try:
          # Try as int.
          intval = int(val)
      except ValueError:
          # Try as rgb.
          try:
              r, g, b = (int(x.strip()) for x in val.split(','))
          except ValueError:
              if ',' in val:
                  # User tried rgb value and failed.
                  raise InvalidColr(val)
  
              # Try as name (fore/back have the same names)
              code = codes['fore'].get(val, None)
              if code:
                  # Valid basic code from fore, bask, or style.
                  return val
  
              # Not a basic code, try known names.
              named_data = name_data.get(val, None)
              if named_data is not None:
                  # A known named color.
                  return val
  
              # Not a basic/extended/known name, try as hex.
              try:
                  if rgb_mode:
                      return hex2rgb(val, allow_short=True)
                  return hex2termhex(val, allow_short=True)
              except ValueError:
                  raise InvalidColr(val)
          else:
              # Got rgb. Do some validation.
              if not all((in_range(x, 0, 255) for x in (r, g, b))):
                  raise InvalidColr(val)
              # Valid rgb.
              return r, g, b
      else:
          # Int value.
          if not in_range(intval, 0, 255):
              # May have been a hex value confused as an int.
              if len(val) in (3, 6):
                  try:
                      if rgb_mode:
                          return hex2rgb(val, allow_short=True)
                      return hex2termhex(val, allow_short=True)
                  except ValueError:
                      raise InvalidColr(val)
              raise InvalidColr(intval)
          # Valid int value.
          return intval