Trying to implement HTTPie's CLI with docopt.

  • Download Gist
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#!/usr/bin/env python
HTTPie - cURL for humans. <>
Positional arguments:
These arguments come after any flags and in the order they are listed
here. Only URL is required.
METHOD The HTTP method to be used for the request (GET, POST,
PUT, DELETE, PATCH, ...). If this argument is omitted,
then HTTPie will guess the HTTP method. If there is
some data to be sent, then it will be POST, otherwise
URL The protocol defaults to http:// if the URL does not
include one.
REQUEST ITEM A key-value pair whose type is defined by the
separator used. It can be an HTTP header
(header:value), a data field to be used in the request
body (field_name=value), a raw JSON data field
(field_name:=value), a query parameter (name==value),
or a file field (field_name@/path/to/file). You can
use a backslash to escape a colliding separator in the
field name.
Suggestions and bug reports are greatly appreciated:
from docopt import docopt
if __name__ == '__main__':
arguments = docopt(__doc__, version='0.3.1')

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.