__author__ = 'romain.gilles'

from web import HTTP_METHODS, HTTP_GET, uri, request

__author__ = 'Romain Gilles'
import argparse

version='${version}'


def validate_method(method):
    return method in HTTP_METHODS

def main():
    parser = argparse.ArgumentParser(description='Process uri to create request.')
    parser.add_argument('--version', action='version', version='%(prog)s {0}'.format(version))
    parser.add_argument('uri', help="the uri where the request will be sent")
    parser.add_argument('-X', '--request', help="(HTTP) Specifies a custom request method to use when communicating with the HTTP server. The specified request will be used instead of the method otherwise used (which defaults to GET). Read the HTTP 1.1 specification for details and explanations. (Common additional HTTP requests include PUT and DELETE, but related technologies like WebDAV offers PROPFIND, COPY, MOVE and more). It can be: {0}".format(", ".join(HTTP_METHODS)), default = HTTP_GET)
    parser.add_argument('-G', '--get', action='store_true', help="Activate the get method")
    parser.add_argument('--put', action='store_true', help="Activate the put method")
    parser.add_argument('--post', action='store_true', help="Activate the post method")
    parser.add_argument('--del', action='store_true', help="Activate the delete method")
    parser.add_argument('--head', action='store_true', help="Activate the head method")
    args = parser.parse_args()
    target = uri(args.uri)
    if not validate_method(args.request):
        parser.error("invalid method name: {0}".format(args.request))

    response = request(target, args.request)
    print(str(response))

@@ -130,17 +130,19 @@
 %0Aversion
-=
+ = 
 '$%7Bversi
@@ -212,16 +212,17 @@
 ETHODS%0A%0A
+%0A
 def main
@@ -523,16 +523,40 @@
 equest',
+%0A                       
  help=%22(
@@ -958,16 +958,45 @@
 .format(
+%0A                            
 %22, %22.joi
@@ -1020,19 +1020,17 @@
  default
- = 
+=
 HTTP_GET
@@ -1031,16 +1031,21 @@
 TP_GET)%0A
+    #
     pars
@@ -1120,32 +1120,37 @@
 he get method%22)%0A
+    #
     parser.add_a
@@ -1211,32 +1211,37 @@
 he put method%22)%0A
+    #
     parser.add_a
@@ -1304,32 +1304,37 @@
 e post method%22)%0A
+    #
     parser.add_a
@@ -1402,24 +1402,29 @@
 te method%22)%0A
+    #
     parser.a

introduce new python module file to share the curi main management