aboutsummaryrefslogtreecommitdiff
path: root/ponysay
diff options
context:
space:
mode:
authorjaseg <s@jaseg.de>2013-07-29 19:29:32 +0200
committerjaseg <s@jaseg.de>2013-07-29 19:56:31 +0200
commit13f954f4ecace0c4888e194c75a26666fa3fc305 (patch)
tree73935ab0012f0e722efee915ecb77af58b930350 /ponysay
parent1466970c712fbd3f8579fdc995acc80e0e115299 (diff)
downloadponysay-13f954f4ecace0c4888e194c75a26666fa3fc305.tar.gz
ponysay-13f954f4ecace0c4888e194c75a26666fa3fc305.tar.bz2
ponysay-13f954f4ecace0c4888e194c75a26666fa3fc305.zip
Added a proper setup.py
Diffstat (limited to 'ponysay')
-rw-r--r--ponysay51
1 files changed, 51 insertions, 0 deletions
diff --git a/ponysay b/ponysay
new file mode 100644
index 0000000..65a0339
--- /dev/null
+++ b/ponysay
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+
+import os, sys, random
+from os.path import dirname, realpath, exists
+import ponysay
+import argparse, textwrap
+
+if __name__ == '__main__':
+ termwidth = 80
+ try:
+ termwidth = os.get_terminal_size()[0]
+ except:
+ pass
+
+ parser = argparse.ArgumentParser(description='Cowsay with ponies')
+ parser.add_argument('-p', '--pony', type=str, default='random', help='The name of the pony to be used. Use "-p list" to list all ponies, "-p random" (default) to use a random pony.')
+ parser.add_argument('-q', '--quote', action='store_true', help='Use a random quote of the pony being displayed as text')
+ parser.add_argument('-c', '--center', action='store_true', help='Use a random quote of the pony being displayed as text')
+ parser.add_argument('-C', '--center-text', action='store_true', help='Center the text in the bubble')
+ parser.add_argument('-w', '--width', type=int, default=termwidth, help='Terminal width. Use 0 for unlimited width. Default: autodetect')
+ parser.add_argument('-b', '--balloon', type=str, default='cowsay', help='Balloon style to use. Use "-b list" to list available styles.')
+ parser.add_argument('text', type=str, nargs='*', help='The text to be placed in the speech bubble')
+ args = parser.parse_args()
+
+ think = sys.argv[0].endswith('think')
+ if args.pony == "list":
+ print('\n'.join(sorted(ponysay.list_ponies() if not args.quote else ponysay.list_ponies_with_quotes())))
+ sys.exit()
+ if args.balloon == 'list':
+ print('\n'.join([ s.replace('.think', '') for s in ponysay.balloonstyles.keys() if s.endswith('.think') == think ]))
+ sys.exit()
+ pony = args.pony
+ if pony == "random":
+ pony = random.choice(ponysay.list_ponies() if not args.quote else ponysay.list_ponies_with_quotes())
+ text = ' '.join(args.text) or None
+ if text == '-':
+ text = '\n'.join(sys.stdin.readlines())
+ if args.quote:
+ text = ponysay.random_quote(pony)
+
+ balloonstyle = None
+ if think:
+ balloonstyle = ponysay.balloonstyles[args.balloon+'.think']
+ else:
+ balloonstyle = ponysay.balloonstyles[args.balloon]
+
+ print(ponysay.render_pony(pony, text,
+ balloonstyle=balloonstyle,
+ width=args.width or sys.maxint,
+ center=args.center,
+ centertext=args.center_text))