httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
32.7k stars 3.67k forks source link

Allow XDG_CONFIG_HOME usage also on Windows #1520

Open Destroy666x opened 11 months ago

Destroy666x commented 11 months ago

Checklist


Enhancement request

It would be nice if Windows also supported and prioritized XDG_CONFIG_HOME env var, if set. While it's not a common standard, it can be easily set by the user and a bunch of cross-system applications support it. Examples: git, github, 0install, ... I know you can use HTTPIE_CONFIG_DIR instead, ut cluttering env vars with lots of vars for different apps isn't too tidy.


Problem it solves

It makes Windows setup a bit easier in certain scenarios, for example with configs saved on cloud, for cross-system configuration.


Additional information, screenshots, or code examples

The change should be as simple as modifying https://github.com/httpie/httpie/blob/30a6f73ec806393d897247b4c7268832de811ff7/httpie/config.py#L41 to:

        xdg_config_home_dir = os.environ.get(ENV_XDG_CONFIG_HOME)
        if xdg_config_home_dir:
            return Path(xdg_config_home_dir) / DEFAULT_CONFIG_DIRNAME
        else:
            return DEFAULT_WINDOWS_CONFIG_DIR

or anything alike, e.g. you could ensure that the subdir exists in that dir as well.