|
| 1 | + |
| 2 | +""" |
| 3 | +cli/cLI.py |
| 4 | +executable python file of quickping as command-line tools |
| 5 | +""" |
| 6 | + |
| 7 | +import click |
| 8 | +from quickping import Quickping |
| 9 | + |
| 10 | +@click.command(context_settings=dict(help_option_names=['-h', '--help'])) |
| 11 | +@click.option('-s', '--start', default="", required=True, type=str, help='start range of IPv4 address') |
| 12 | +@click.option('-e', '--end', default="", required=True, type=str, help='end range of IPv4 address') |
| 13 | +@click.option('-t', '--threads', default=512, type=int, help='number of threads') |
| 14 | +@click.option('-l', '--log', default=False, type=bool, help='display logging') |
| 15 | +def cLI(start, end, threads, log): |
| 16 | + |
| 17 | + try: |
| 18 | + testRange = Quickping(start=start, end=end, ignore=[], threads=threads, log=log) |
| 19 | + testRange.active() |
| 20 | + except expression as identifier: |
| 21 | + raise identifier from None |
| 22 | + |
| 23 | + print('\nActive Addresses\n') |
| 24 | + for aa in testRange.activeAddresses: |
| 25 | + print(aa) |
| 26 | + |
| 27 | + informations = """\nStart at : {}\nEnd at : {}\nTotal Addresses : {}\nActive Addresses : {}\nNumber of Threads : {}""".format( |
| 28 | + testRange.start, |
| 29 | + testRange.end, |
| 30 | + len(testRange.addresses), |
| 31 | + len(testRange.activeAddresses), |
| 32 | + testRange.threads) |
| 33 | + click.echo(informations) |
| 34 | + |
| 35 | +if __name__ == "__main__": |
| 36 | + cLI() |
| 37 | + |
0 commit comments