dotfiles/bin/welcome.py

104 lines
2.7 KiB
Python
Raw Normal View History

2022-04-29 10:36:13 -05:00
#!/usr/bin/env python3
from rich.console import Console
from rich.text import Text
import argparse
console = Console(force_terminal=True)
colors = [
"black",
"red",
"green",
"yellow",
"blue",
"magenta",
"cyan",
"white",
"bright_black",
"bright_red",
"bright_green",
"bright_yellow",
"bright_blue",
"bright_magenta",
"bright_cyan",
"bright_white",
]
def wave():
"""
"""
lines = ["╮╭╭╮╮╭╭╮╮╭╭╮╮╭╭╮", "╰╯╯╰╰╯╯╰╰╯╯╰╰╯╯╰"]
for line in lines:
styled_line = [
Text(line[i * 2 : i * 2 + 2], style=color)
for i, color in enumerate(colors[:8])
]
console.print(Text("").join(styled_line))
def dots():
"""
"""
console.print(Text(" ").join([Text("", style=color) for color in colors[:8]]))
2022-07-12 12:11:51 -05:00
def double_dots():
"""
"""
console.print(Text(" ").join([Text("", style=color) for color in colors[:8]]))
console.print(Text(" ").join([Text("", style=color) for color in colors[8:]]))
2022-04-29 10:36:13 -05:00
def wave_w_dots():
"""
Alternating colors from red to white with
black separators
"""
lines = ["╮╮●╭╭╭─╮╮╮●╭╭╭─╮╮╮●╭╭╭─╮╮╮●╭╭", "╰╰─╯╯╯●╰╰╰─╯╯╯●╰╰╰─╯╯╯●╰╰╰─╯╯"]
for line in lines:
styled_line = []
for i, x in enumerate(line):
if i % 4:
styled_line.append(Text(x, style=colors[1 + int(i / 4)]))
else:
styled_line.append(Text(x, style="black"))
console.print(Text("").join(styled_line))
def main():
2022-07-12 12:11:51 -05:00
prompts = {"wave": wave, "dots": dots,'double-dots':double_dots, "wave-dots": wave_w_dots}
2022-04-29 10:36:13 -05:00
parser = argparse.ArgumentParser(
2022-07-12 12:11:51 -05:00
description="generate ansi color coded login prompts"
2022-04-29 10:36:13 -05:00
)
parser.add_argument("--welcome", type=str, help="a welcome screen to print")
args = parser.parse_args()
if not args.welcome:
for name, prompt in prompts.items():
console.print(f"name: {name}")
prompt()
elif args.welcome not in prompts.keys():
console.print(f"{args.welcome} is not a registered prompt")
else:
2022-07-12 12:11:51 -05:00
console.print()
2022-04-29 10:36:13 -05:00
prompts[args.welcome]()
if __name__ == "__main__":
main()