Threading Library Base

This commit is contained in:
Michael Skelton
2018-10-23 21:15:33 +10:00
parent 6aa0396b1f
commit 1843319861
9 changed files with 755 additions and 19 deletions

View File

@@ -10,6 +10,14 @@ class InputHelper(object):
else:
return open(arg, 'r') # return an open file handle
@staticmethod
def check_positive(parser, arg):
ivalue = int(arg)
if ivalue <= 0:
raise parser.ArgumentTypeError("%s is not a valid positive integer!" % arg)
return arg
@staticmethod
def process_targets(arguments):
targets = set()
@@ -59,6 +67,13 @@ class InputParser(object):
type=lambda x: InputHelper.readable_file(parser, x)
)
parser.add_argument(
'-threads', dest='threads', required=False,
help="Specify the maximum number of threads to run (DEFAULT:5).",
default=5,
type=lambda x: InputHelper.check_positive(parser, x)
)
commands = parser.add_mutually_exclusive_group(required=True)
commands.add_argument(
'-c', dest='command',
@@ -72,25 +87,6 @@ class InputParser(object):
type=lambda x: InputHelper.readable_file(parser, x)
)
output = parser.add_mutually_exclusive_group()
output.add_argument(
'-oN', dest='output_normal',
help='Normal output printed to a file when the -oN option is '
'specified with a filename argument.'
)
output.add_argument(
'-oJ', dest='output_json',
help='JSON output printed to a file when the -oJ option is '
'specified with a filename argument.'
)
output.add_argument(
'-oG', dest='output_grepable',
help='Grepable output printed to a file when the -oG option is '
'specified with a filename argument.'
)
parser.add_argument(
'--no-color', dest='nocolor', action='store_true', default=False,