Deprecate usage of -h as short form for --headers
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.
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.