diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2014-10-25 08:18:39 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2014-10-25 08:18:39 +1300 |
commit | 5aadf92767614b7bd8e2ef677085410ac359e5e8 (patch) | |
tree | 560778bba2ac6a2e6cc7a0b69bb042987ef67435 /libpathod/cmdline.py | |
parent | 3de68da3adf15f445e40412fdde4b94857640166 (diff) | |
download | mitmproxy-5aadf92767614b7bd8e2ef677085410ac359e5e8.tar.gz mitmproxy-5aadf92767614b7bd8e2ef677085410ac359e5e8.tar.bz2 mitmproxy-5aadf92767614b7bd8e2ef677085410ac359e5e8.zip |
Nicer way to specify patterns read for file - just use a path
Diffstat (limited to 'libpathod/cmdline.py')
-rw-r--r-- | libpathod/cmdline.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/libpathod/cmdline.py b/libpathod/cmdline.py index 6d1573f1..2c6e094e 100644 --- a/libpathod/cmdline.py +++ b/libpathod/cmdline.py @@ -1,7 +1,8 @@ #!/usr/bin/env python import argparse -import sys import os +import os.path +import sys from . import pathoc, pathod, version, utils from netlib import http_uastrings @@ -50,9 +51,11 @@ def go_pathoc(): ) parser.add_argument( 'request', type=str, nargs="+", - help='Request specification' + help=""" + Request specification, or path to a file containing a request + specifcation + """ ) - group = parser.add_argument_group( 'SSL', ) @@ -141,6 +144,16 @@ def go_pathoc(): args.connect_to = parts else: args.connect_to = None + + reqs = [] + for r in args.request: + if os.path.exists(r): + data = open(r).read() + reqs.append(data) + else: + reqs.append(r) + args.request = reqs + pathoc.main(args) @@ -174,7 +187,10 @@ def go_pathod(): type=str, action="append", metavar="ANCHOR", - help='Add an anchor. Specified as a string with the form pattern=pagespec' + help=""" + Add an anchor. Specified as a string with the form pattern=pagespec, or + pattern=filepath + """ ) parser.add_argument( "-c", dest='craftanchor', default="/p/", type=str, @@ -310,5 +326,14 @@ def go_pathod(): parser.error(v) args.sizelimit = sizelimit + anchors = [] + for patt, spec in anchors: + if os.path.exists(spec): + data = open(spec).read() + anchors.append((patt, data)) + else: + anchors.append((patt, spec)) + args.anchors = anchors + pathod.main(args) |