123456789101112131415161718192021222324 |
- 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()
|