Skip to content

Instantly share code, notes, and snippets.

@jedsmith
Last active January 10, 2018 01:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedsmith/1422c5e677c4a1feb7022a4c1496b275 to your computer and use it in GitHub Desktop.
Save jedsmith/1422c5e677c4a1feb7022a4c1496b275 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import argparse
import string
TABLE = {letter: f':parrot-{letter}:' for letter in string.ascii_lowercase}
arguments = argparse.ArgumentParser(description="Party parrot text-o-matic.")
arguments.add_argument('words', metavar='TEXT', type=str, nargs='+',
help="text to make badass")
arguments.add_argument('--weak', dest='separator', action='store_const',
const=' ', default=':parrot:', help="preserve spaces in input, weak")
options = arguments.parse_args()
final = len(options.words) - 1
for i, word in enumerate(options.words):
separator = "" if i == final else options.separator
print("".join(TABLE.get(let, let) for let in word.lower()), end=separator)
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment