Closed bbiskup closed 7 years ago
After digging around with curl for a while, I found that
It would be nice if httpstat did not depend on the position of the URL
is very hard to achieve. curl actually don't care the position of URL, whether URL is at first, or last, or in the middle, as long as the other arguments follow the rules, curl can parse the inputs correctly.
As to httpstat, we couldn't just pass all the arguments to curl directly, we have to find out the URL to decide whether to use http or https display template. Specify position is the easiest way to help getting the URL, if not specify, we have to implement an argument parser the same as curl's, which is not an easy work. In that case, whether the position is first or last doesn't make much difference, since both will still have invocation valid to curl but invalid to itself. What do you think?
Thank you for the prompt reply. I think replicating curl
's command-line parsing or adding a library dependency would overkill. Nevertheless, I would suggest a comment making it clear to first-time users that the URL needs to be given first, because
curl --help
gives prints this usage:
curl [options...] <url>
curl
manpage gives examples with options and URL in any orderAnyway, it is a minor issue or even just a matter of habit.
Actually the usage has made it clear that the URL should be put at the first position:
$ python httpstat.py
Usage: httpstat URL [CURL_OPTIONS]
httpstat -h | --help
httpstat --version
The time I was considering the URL's position, I was thinking that httpstat itself actually has no option. So it should be distinguished from normal situation, where intuitively options are put after command and before the main arguments. Thus when you see httpstat URL [CURL_OPTIONS]
, it becomes very clear that the curl options are just for curl, and will definitely have no effect on how httpstat will perform. All the options for httpstat, are environment variables, separately.
In conclusion, the position of URL won't be changed, thanks for your suggestion and cooperation :)
P.S. it's easy to modify the code for your own to make URL at the last position, just change L180 to url = args[-1]
and L88 to curl_args = args[:-1]
.
An invocation that would be valid with cURL:
curl -X GET http://www.google.de/
gives the following error with httpstat:
whereas the command
httpstat http://www.google.de/ -X GET
is parsed successfully.
It would be nice if
httpstat
did not depend on the position of the URL. In my concrete example, the cURL command was generated by Flask-RESTPlus Swagger documentation.