cli icon indicating copy to clipboard operation
cli copied to clipboard

Improve CLI usability (positional arguments order)

Open jkbrzt opened this issue 10 years ago • 3 comments

Either allow request items to be specified before URL or improve the error message.

https://twitter.com/akrabat/status/488285985672019968

image

jkbrzt avatar Jul 14 '14 09:07 jkbrzt

Positional arguments:

  • The URL argument is the first positional one. It’s the only required argument.
  • After that, other positional arguments—request items—may optionally follow.

Arguments order:

  • If we allow random order of the positional arguments, then we’d have to introduce a detection for which of the arguments represent the URL. We can no longer rely on it being first.
  • This might be doable, but there’ll be a bunch of edge cases where it’s not straightforward or impossible, for example, the one below.
  • Detecting a request item type easy, because they differ in the separator used.
# An example of an ambiguous random-order positional argument set:
$ http     pie.dev/post            httpie.io/a=a
           ^^^^^^^^^^^^            ^^^^^^^^^^^^^^
             Valid URL       Both valid URL & data field 

jkbrzt avatar Feb 10 '21 14:02 jkbrzt

Can I take up this issue??...... Is it still open??

RakshithRAcharya avatar May 25 '21 11:05 RakshithRAcharya

I don’t think REQUEST_ITEMs need to be allowed to come before the URL but it sure would be great if the ---prefixed options would be allowed everywhere.

Specifically, I often need to switch the HTTP verb. The fact that it cannot be simply added after http but instead needs to be inserted between the last option and the URL, makes it difficult to edit an existing command.

I.e. allow http post --auth admin in addition to http --auth admin post.

While we’re at it, a shorthand for --verify=no would also be appreciated.

EDIT: See #125 and #1536

sabberworm avatar Feb 06 '24 17:02 sabberworm