Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Trying to implement HTTPie's CLI with docopt.
#!/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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment