-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.py
80 lines (67 loc) · 1.98 KB
/
gen.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
import signal
from utils import console
from utils import files
files.check_files()
from gens import fake_names
from gens import random_string
from gens import syllable_words
from gens import random_words
options = [
{
"name": "Fake names",
"description": "Generates X fake names",
"function": fake_names.main
},
{
"name": "Random strings",
"description": "Generates X random strings",
"function": random_string.main
},
{
"name": "Syllable words",
"description": "Generates X words with specific syllable count",
"function": syllable_words.main
},
{
"name": "Random words",
"description": "Generates X random words",
"function": random_words.main
}
]
def on_exit(signal, frame, empty_space=True):
if empty_space:
print()
console.info("Exiting...")
exit(0)
def select_menu():
console.resize(68, 40)
console.set_title("MC Name Generator")
console.clear()
console.generator_banner()
console.info("Options:")
for option in options:
console.option(option["name"], option["description"])
print()
chosen_option = console.user_input("What do you want to generate (q to exit)? ")
if chosen_option.lower() == "q":
on_exit(None, None, empty_space=False)
return chosen_option
def main():
global in_gen
while True:
chosen_option = select_menu()
for option in options:
if option["name"].lower() == chosen_option:
console.clear()
console.generator_banner()
console.set_title("MC Name Generator - " + option["name"])
option["function"]()
break
else:
console.error("Invalid option")
console.user_input("Press enter to start over...")
console.clear()
console.generator_banner()
if __name__ == "__main__":
signal.signal(signal.SIGINT, on_exit)
main()