48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
# Script to accept command line text and output to a rich panel console
|
|
from rich.console import Console
|
|
from rich.panel import Panel
|
|
from rich.prompt import Prompt
|
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
console = Console()
|
|
|
|
import argparse
|
|
|
|
def gather_args():
|
|
# Create the parser
|
|
parser = argparse.ArgumentParser(description='Example script to demonstrate argparse usage.')
|
|
|
|
# Add the '-m'/'--message' argument
|
|
parser.add_argument('-m', '--message', type=str, help='Input message', required=True)
|
|
|
|
# Add the '-s'/'--style' argument
|
|
parser.add_argument('-s', '--style', type=str, help='Input style', required=True)
|
|
|
|
# Parse the arguments
|
|
args = parser.parse_args()
|
|
|
|
# Print the parsed arguments
|
|
print(f"Message: {args.message}")
|
|
print(f"Style: {args.style}")
|
|
|
|
return args.message, args.style
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# Gather the arguments
|
|
message, style = gather_args()
|
|
message = "\n " + message + "\n"
|
|
|
|
|
|
# Styles: bold, italic, underline, reverse, blink, conceal, strike, dim, invisible
|
|
# Colors: black, red, green, yellow, blue, magenta, cyan, white
|
|
# Backgrounds: on_black, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white
|
|
|
|
|
|
print()
|
|
panel = Panel(message, title="Attention", style=style)
|
|
console.print(panel)
|
|
print() |