Created
February 5, 2013 03:26
-
-
Save prafulfillment/4711926 to your computer and use it in GitHub Desktop.
Trying to implement HTTPie's CLI with docopt.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
usage: http [METHOD] <URL> [REQUEST ITEM [REQUEST ITEM ...]] | |
HTTPie - cURL for humans. <http://httpie.org> | |
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 | |
GET. | |
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: | |
https://github.com/jkbr/httpie/issues | |
""" | |
from docopt import docopt | |
if __name__ == '__main__': | |
arguments = docopt(__doc__, version='0.3.1') | |
print(arguments) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment