-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandLine.py
59 lines (46 loc) · 1.77 KB
/
CommandLine.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
import argparse, time
import sys
from cor import CleanGABC
RED = '\033[31m' # Rouge
GREEN = '\033[32m' # Vert
YELLOW = '\033[33m' # Jaune
RESET = '\033[0m' # Réinitialiser la couleur
class Command:
@staticmethod
def print_help():
print("""
Usage: Clean-gabc [OPTION] FILE
Options:
-h, --help Print this help text and exit
-c, --color Color text for read
-o, --output Path for the result
""")
def run(self):
parser = argparse.ArgumentParser(description="Clean GABC tool")
parser.add_argument("-c", "--color",action='store_true', required=False)
parser.add_argument("-o", "--output", type=str, required=False, help="Path for the result")
parser.add_argument("file", type=str, help="Input file")
score = CleanGABC()
try:
time_0 = time.time()
args = parser.parse_args()
if args.output:
result = score.clean(args.file, args.output)
else:
result = score.clean(args.file, args.file)
if args.color:
score.color_text(result)
time_1 = time.time()
print(f"Execution de la tâche en : {time_1 - time_0 : .6f} seconde")
except SystemExit as e:
print(RED+"[erro]"+RESET+" Arguments non valides.")
print("Utilisez -h ou --help pour voir l'aide.")
sys.exit(1)
def main():
if len(sys.argv) == 1 or '-h' in sys.argv or '--help' in sys.argv:
Command.print_help()
sys.exit(0)
command_instance = Command()
command_instance.run()
if __name__ == "__main__":
main()