xh icon indicating copy to clipboard operation
xh copied to clipboard

Deprecate usage of -h as short form for --headers

Open ducaale opened this issue 4 years ago • 1 comments

Most rust-based CLI tools, including ripgrep, show a compact or a detailed help page depending on whether -h or --help flag has been used. Unfortunately, Httpie and, by extension, xh use -h as a short form for --headers.

To be both backward compatible and align with the behavior of other rust-based CLI tools, I propose that we treat -h as --headers only when a user passes URL to the command:

$ xh -h
xh 0.14.1
xh is a friendly and fast tool for sending HTTP requests.

USAGE:
    xh [OPTIONS] <[METHOD] URL> [--] [REQUEST_ITEM]...
...

$ xh httpbin.org/json -h
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 429
Content-Type: application/json
Date: Thu, 23 Dec 2021 17:56:10 GMT
Server: gunicorn/19.9.0

Current behavior:

$ xh -h
error: The following required arguments were not provided:
    <[METHOD] URL>

USAGE:
    xh <[METHOD] URL> --headers

For more information try --help

$ xh httpbin.org/json -h
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 429
Content-Type: application/json
Date: Thu, 23 Dec 2021 17:56:10 GMT
Server: gunicorn/19.9.0

The only issue I can see is when a user adds -h to a valid xh command and expects help output. But I think that is an acceptable compromise.

ducaale avatar Dec 23 '21 18:12 ducaale

The next version of HTTPie will be 3.0, which will be a breaking change. So I asked in https://github.com/httpie/httpie/issues/428 if they could consider changing -h to be short-form for --help instead of --headers, but it seems unlikely that would happen.

ducaale avatar Dec 23 '21 18:12 ducaale