Preparing git repo for final project
This commit is contained in:
24
problems/pset4/figlet/figlet.py
Normal file
24
problems/pset4/figlet/figlet.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import sys
|
||||
|
||||
from pyfiglet import Figlet
|
||||
|
||||
figlet = Figlet()
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) > 1:
|
||||
if len(sys.argv) != 3:
|
||||
sys.exit("This script takes 2 or no command-line arguments")
|
||||
if sys.argv[1] not in ('-f', '--font'):
|
||||
sys.exit(f"Unknown option `{sys.argv[1]}`")
|
||||
available_fonts = figlet.getFonts()
|
||||
font = sys.argv[2]
|
||||
if font not in available_fonts:
|
||||
sys.exit(f"Unknown font `{sys.argv[2]}`")
|
||||
figlet.setFont(font=font)
|
||||
input_text = input("Input: ")
|
||||
print(figlet.renderText(input_text))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user