mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-17 14:54:21 +01:00
Merge pull request #100 from mzfr/repeat
Add option to repeat the command
This commit is contained in:
@@ -7,23 +7,29 @@ from Interlace.lib.core.output import OutputHelper, Level
|
|||||||
from Interlace.lib.threader import Pool
|
from Interlace.lib.threader import Pool
|
||||||
|
|
||||||
|
|
||||||
def build_queue(arguments, output):
|
def build_queue(arguments, output, repeat):
|
||||||
task_list = InputHelper.process_commands(arguments)
|
task_list = InputHelper.process_commands(arguments)
|
||||||
for task in task_list:
|
for task in task_list:
|
||||||
output.terminal(Level.THREAD, task.name(), "Added to Queue")
|
output.terminal(Level.THREAD, task.name(), "Added to Queue")
|
||||||
print('Generated {} commands in total'.format(len(task_list)))
|
print('Generated {} commands in total'.format(len(task_list)))
|
||||||
return task_list
|
print('Repeat set to {}'.format(repeat))
|
||||||
|
return task_list * repeat
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = InputParser()
|
parser = InputParser()
|
||||||
arguments = parser.parse(sys.argv[1:])
|
arguments = parser.parse(sys.argv[1:])
|
||||||
|
|
||||||
output = OutputHelper(arguments)
|
output = OutputHelper(arguments)
|
||||||
|
|
||||||
output.print_banner()
|
output.print_banner()
|
||||||
|
|
||||||
pool = Pool(arguments.threads, build_queue(arguments, output), arguments.timeout, output, arguments.sober)
|
if arguments.repeat:
|
||||||
|
repeat = int(arguments.repeat)
|
||||||
|
else:
|
||||||
|
repeat = 1
|
||||||
|
|
||||||
|
|
||||||
|
pool = Pool(arguments.threads, build_queue(arguments, output, repeat), arguments.timeout, output, arguments.sober)
|
||||||
pool.run()
|
pool.run()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -438,6 +438,11 @@ class InputParser(object):
|
|||||||
help='If set then progress bar will be stripped out'
|
help='If set then progress bar will be stripped out'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--repeat', dest='repeat',
|
||||||
|
help='repeat the given command x number of times.'
|
||||||
|
)
|
||||||
|
|
||||||
output_types = parser.add_mutually_exclusive_group()
|
output_types = parser.add_mutually_exclusive_group()
|
||||||
output_types.add_argument(
|
output_types.add_argument(
|
||||||
'-v', '--verbose', dest='verbose', action='store_true', default=False,
|
'-v', '--verbose', dest='verbose', action='store_true', default=False,
|
||||||
|
|||||||
Reference in New Issue
Block a user