Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ducaale opened this issue Dec 23, 2021 · 1 comment
Open

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

ducaale opened this issue Dec 23, 2021 · 1 comment

Comments

@ducaale
Copy link
Owner

ducaale commented Dec 23, 2021

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
Copy link
Owner Author

ducaale commented Dec 23, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant