def get_egrc_config(cli_egrc_path):
    """
    Return a Config namedtuple based on the contents of the egrc.

    If the egrc is not present, it returns an empty default Config.

    This method tries to use the egrc at cli_egrc_path, then XDG_CONFIG_HOME,
    and then the default path.

    cli_egrc_path: the path to the egrc as given on the command line via
        --config-file
    """
    # We have to be a little crafty here, because we want to support people
    # having an XDG_CONFIG_HOME dir that doesn't contain the config file. This
    # will allow a smooth transition for XDG users that started using eg when we
    # only supported `~/.egrc`. We don't want to suddenly break for them when we
    # add new support.
    config_path = ''

    if cli_egrc_path:
      # cli values always win
      config_path = get_expanded_path(cli_egrc_path)

    if config_path == '':
      # Try for the xdg config.
      # The freedesktop.org spec says '$HOME/.config' should be used if the
      # environment variable is not set or is empty. os.getenv() will be falsey
      # if it is either not set (None) or an empty string.
      default_xdg_dir = os.path.join('~', '.config')
      xdg_home_dir = os.getenv('XDG_CONFIG_HOME') or default_xdg_dir

      xdg_config_path = os.path.join(xdg_home_dir, 'eg', 'egrc')
      xdg_config_path = get_expanded_path(xdg_config_path)
      if os.path.isfile(xdg_config_path):
        config_path = xdg_config_path

    if config_path == '':
      # Fall back to our home directory.
      config_path = get_expanded_path(DEFAULT_EGRC_PATH)


    # Start as if nothing was defined in the egrc.
    egrc_config = get_empty_config()

    if os.path.isfile(config_path):
        egrc_config = get_config_tuple_from_egrc(config_path)

    return egrc_config

    Return a Config namedtuple based on the contents of the egrc.

    If the egrc is not present, it returns an empty default Config.

    This method tries to use the egrc at cli_egrc_path, then XDG_CONFIG_HOME,
    and then the default path.

    cli_egrc_path: the path to the egrc as given on the command line via
        --config-file
    
eg/config.py