diff options
-rw-r--r-- | libpathod/pathoc.py | 3 | ||||
-rwxr-xr-x | pathoc | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index 0cc0466d..90f3b98b 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -49,6 +49,8 @@ class Pathoc(tcp.TCPClient): explain: Print request explanation hexdump: When printing requests or responses, use hex dump output ignorecodes: Sequence of return codes to ignore + + Returns True if we have a non-ignored response. """ try: r = rparse.parse_request(self.settings, spec) @@ -94,3 +96,4 @@ class Pathoc(tcp.TCPClient): else: if resp: self._show_summary(fp, *resp) + return True @@ -36,13 +36,17 @@ if __name__ == "__main__": group = parser.add_argument_group('Controlling Output') group.add_argument( "-c", dest="ignorecodes", type=str, default="", - help="Comma-separated list of response codes filter" + help="Comma-separated list of response codes to ignore" ) group.add_argument( "-e", dest="explain", action="store_true", default=False, help="Explain requests" ) group.add_argument( + "-o", dest="oneshot", action="store_true", default=False, + help="Oneshot - exit after first non-ignored response" + ) + group.add_argument( "-q", dest="showreq", action="store_true", default=False, help="Print full request" ) @@ -84,7 +88,7 @@ if __name__ == "__main__": if args.timeout: p.settimeout(args.timeout) for spec in args.request: - p.print_request( + ret = p.print_request( spec, showreq=args.showreq, showresp=args.showresp, @@ -93,6 +97,8 @@ if __name__ == "__main__": ignorecodes=codes ) sys.stdout.flush() + if ret and args.oneshot: + sys.exit(0) except KeyboardInterrupt: pass |