Queer European MD passionate about IT

figlet.py 621 B

123456789101112131415161718192021222324
  1. import sys
  2. from pyfiglet import Figlet
  3. figlet = Figlet()
  4. def main():
  5. if len(sys.argv) > 1:
  6. if len(sys.argv) != 3:
  7. sys.exit("This script takes 2 or no command-line arguments")
  8. if sys.argv[1] not in ('-f', '--font'):
  9. sys.exit(f"Unknown option `{sys.argv[1]}`")
  10. available_fonts = figlet.getFonts()
  11. font = sys.argv[2]
  12. if font not in available_fonts:
  13. sys.exit(f"Unknown font `{sys.argv[2]}`")
  14. figlet.setFont(font=font)
  15. input_text = input("Input: ")
  16. print(figlet.renderText(input_text))
  17. if __name__ == "__main__":
  18. main()