-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
67 lines (54 loc) · 1.8 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
import click
from art import logo
from utils import (check_order_details, cls, create_batch_order_with_body,
create_batch_order_with_query)
@click.group()
def cli():
"""Click-specific function, initiates a group."""
pass
@cli.command()
def gui():
"""Shows GUI."""
print(logo)
while True:
choice = input(
"\nPlease choose one of the following:\n1 - Create Batch Order Using A Body\n2 - Create Batch Order Using "
"A Query\n3 - Check Order Details\n4 - Exit\n"
)
cls()
match choice:
case "1":
create_batch_order_with_body()
case "2":
create_batch_order_with_query()
case "3":
while True:
try:
order_id = int(input("Please provide order id : "))
check_order_details(order_id)
break
except ValueError:
print("You entered a non-integer value, please try again.")
continue
case "4":
break
@cli.command()
def create_order_with_body():
"""Creates BatchOrder Using Provided By User Body."""
create_batch_order_with_body()
@cli.command()
@click.option("--hours", help="Specify hour mark to look back for products")
def create_order_with_query(hours: str):
"""Creates BatchOrder Using Provided By User Query."""
if hours:
try:
hours = int(hours)
except ValueError:
print("You entered a non-integer value, please try again.")
else:
create_batch_order_with_query(hours)
else:
create_batch_order_with_query()
cli = click.CommandCollection(sources=[cli])
if __name__ == "__main__":
cli()