docs: def _get_arg_parser(func, types, args_and_defaults, delimiter_chars):
      """Return an ArgumentParser for the given function. Arguments are defined
          from the function arguments and their associated defaults.
  
      Args:
          func: function for which we want an ArgumentParser
          types: types to which the command line arguments should be converted to
          args_and_defaults: list of 2-tuples (arg_name, arg_default)
          delimiter_chars: characters used to separate the parameters from their
          help message in the docstring
      """
      _LOG.debug("Creating ArgumentParser for '%s'", func.__name__)
      (description, arg_help) = _prepare_doc(
          func, [x for (x, _) in args_and_defaults], delimiter_chars)
      parser = argparse.ArgumentParser(description=description)
      for ((arg, default), arg_type) in zip_longest(args_and_defaults, types):
          help_msg = arg_help[arg]
          if default is NoDefault:
              arg_type = arg_type or identity_type
              if arg_type == bool:
                  _LOG.debug("Adding optional flag %s.%s", func.__name__, arg)
                  parser.add_argument("--%s" % arg, default=True, required=False,
                                      action="store_false",
                                      help="%s. Defaults to True if not specified"
                                      % help_msg)
              else:
                  _LOG.debug("Adding positional argument %s.%s", func.__name__,
                             arg)
                  parser.add_argument(arg, help=help_msg, type=arg_type)
          else:
              if default is None and arg_type is None:
                  raise ParseThisError("To use default value of 'None' you need "
                                       "to specify the type of the argument '{}' "
                                       "for the method '{}'"
                                       .format(arg, func.__name__))
              arg_type = arg_type or type(default)
              if arg_type == bool:
                  action = "store_false" if default else "store_true"
                  _LOG.debug("Adding optional flag %s.%s", func.__name__, arg)
                  parser.add_argument("--%s" % arg, help=help_msg,
                                      default=default, action=action)
              else:
                  _LOG.debug(
                      "Adding optional argument %s.%s", func.__name__, arg)
                  parser.add_argument("--%s" % arg, help=help_msg,
                                      default=default, type=arg_type)
      return parser