๐Ÿ“ฆ jasonbanboa / python

๐Ÿ“„ figlet.py ยท 37 lines
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
37from sys import argv, exit
from pyfiglet import Figlet
from random import choice

figlet = Figlet()


if len(argv) == 1:
    random_font = True

elif len(argv) == 3 and argv[1] == "-f" or argv[1] == "--font":
    random_font = False

else:
    print("Invalid usage")
    exit(1)


figlet.getFonts()


if random_font == False:
    try:
        figlet.setFont(font=argv[2])
    except:
        print("Invalid usage")
        exit(1)

elif random_font == True:
    font = choice(figlet.getFonts())


user_input = input("Input: ")

print(f"Output: ")
print(figlet.renderText(user_input))