-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
100 lines (79 loc) · 2.85 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#####################################################
# IMPORTS #
#####################################################
import os
import sys
import click
import perfbench
import netbench
import client
import server
import scanarp
# import scanself
#####################################################
# CLICK COMMANDS #
#####################################################
@click.group()
def app_commands():
pass
@click.command()
@click.option("--name", default="World", prompt="Enter a name", help="Name to greet for the hello funtion")
def hello(name):
click.echo(f"Hello {name}!")
PRIORITIES = {
"o": "Optional",
"l": "Low",
"m": "Medium",
"h": "High",
"c": "Critical"
}
@click.command()
@click.argument("priority", type=click.Choice(PRIORITIES.keys()), default="m")
@click.argument("todofile", type=click.Path(exists=False), required=False)
@click.option("--name", "-n", prompt="Enter the todo name", help="Name of the todo item")
@click.option("--description", "-d", prompt="Enter the todo description", help="Description of the todo item")
def add_todo(name, description, priority, todo_file):
file = todo_file if todo_file is not None else "my_todo.txt"
with open(file, "a+") as f:
f.write(f"{PRIORITIES[priority]}: {name} - {description}\n")
@click.command()
def perfbenchmark():
perfbench.getBenchmark()
perfbench.configureBenchmark()
perfbench.runBenchmark()
@click.command()
@click.argument("ip", type=click.STRING, required=True)
@click.argument('packets', type=click.INT, default=10)
def netbenchmark(ip, packets):
netbench.runBenchmark(ip, str(packets))
@click.command()
@click.option("--debug", help="Enable debug mode for terminal output", type=click.BOOL, default=True)
def startclient(debug):
client.wait(debug)
@click.command()
@click.option("--debug", help="Enable debug mode for terminal output", type=click.BOOL, default=True)
def startserver(debug):
server.serve(debug)
@click.command()
def arpscan():
scanarp.scanall()
# @click.command()
# def selfscan():
# scanself.scanme()
#####################################################
# CLICK GROUP #
#####################################################
app_commands.add_command(hello) # Test Command
app_commands.add_command(add_todo) # Test Command
# app_commands.add_command(selfscan) # 0 - Network Scan on Wifi
app_commands.add_command(arpscan)
app_commands.add_command(perfbenchmark)
app_commands.add_command(netbenchmark)
app_commands.add_command(startclient)
app_commands.add_command(startserver)
# TBD ...
#####################################################
# MAIN ENTRY POINT #
#####################################################
if __name__ == "__main__":
app_commands()