38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import argparse
|
|
import shutil
|
|
import subprocess
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Multiplies the vowels.")
|
|
parser.add_argument("string", metavar="STRING", type=str, help="a string")
|
|
parser.add_argument("n", metavar="N", type=int, help="an integer")
|
|
parser.add_argument(
|
|
"--toilet", action="store_true", help="Display large characters"
|
|
)
|
|
parser.add_argument("--cowsay", action="store_true", help="Cow says the string")
|
|
parser.add_argument("--lolcat", action="store_true", help="Display as a rainbow")
|
|
|
|
args = parser.parse_args()
|
|
|
|
ascii_vowels = "aeiouAEIOU"
|
|
table = str.maketrans({v: v * args.n for v in ascii_vowels}) # 🏳️⚧️
|
|
longtext = args.string.translate(table)
|
|
|
|
pipe = []
|
|
if args.toilet and shutil.which("toilet"):
|
|
pipe.append("toilet")
|
|
if args.cowsay and shutil.which("cowsay"):
|
|
pipe.append("cowsay -n")
|
|
if args.lolcat and shutil.which("lolcat"):
|
|
pipe.append("lolcat")
|
|
|
|
if pipe:
|
|
subprocess.run(" | ".join(pipe), input=longtext + "\n", text=True, shell=True)
|
|
else:
|
|
print(longtext)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|