You can download this code by clicking the button below.
This code is now available for download.
This Python script uses the Typer library to create a command-line application that can generate random quotes.
Technology Stack : Typer
Code Type : Command line application
Code Difficulty : Intermediate
from typer import Typer, Argument, Option
from random import choice
import json
app = Typer()
@app.command()
def random_quote():
"""Generate a random quote."""
quotes = [
"The only way to do great work is to love what you do. - Steve Jobs",
"Success is not final, failure is not fatal: It is the courage to continue that counts. - Winston Churchill",
"The future belongs to those who believe in the beauty of their dreams. - Eleanor Roosevelt"
]
selected_quote = choice(quotes)
app.echo(selected_quote)
if __name__ == "__main__":
app()