2012-09-29 22:04:37 +02:00
|
|
|
|
#!/usr/bin/env python3
|
2012-08-20 02:22:12 +02:00
|
|
|
|
# -*- coding: utf-8 -*-
|
2012-08-18 15:25:20 +02:00
|
|
|
|
|
2012-08-20 02:22:12 +02:00
|
|
|
|
'''
|
2012-10-30 01:31:17 +01:00
|
|
|
|
ponysay - Ponysay, cowsay reimplementation for ponies
|
2013-04-03 20:34:46 +02:00
|
|
|
|
|
2013-01-01 01:00:00 +01:00
|
|
|
|
Copyright (C) 2012, 2013 Erkin Batu Altunbaş et al.
|
2012-08-20 02:22:12 +02:00
|
|
|
|
|
2013-04-03 20:34:46 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If you intend to redistribute ponysay or a fork of it commercially,
|
|
|
|
|
it contains aggregated images, some of which may not be commercially
|
|
|
|
|
redistribute, you would be required to remove those. To determine
|
|
|
|
|
whether or not you may commercially redistribute an image make use
|
|
|
|
|
that line ‘FREE: yes’, is included inside the image between two ‘$$$’
|
|
|
|
|
lines and the ‘FREE’ is and upper case and directly followed by
|
|
|
|
|
the colon.
|
2012-08-25 04:36:47 +02:00
|
|
|
|
|
|
|
|
|
|
2013-04-02 11:21:33 +02:00
|
|
|
|
Authors:
|
2012-08-25 04:36:47 +02:00
|
|
|
|
|
|
|
|
|
Erkin Batu Altunbaş: Project leader, helped write the first implementation
|
2012-08-20 02:22:12 +02:00
|
|
|
|
Mattias "maandree" Andrée: Major contributor of both implementions
|
|
|
|
|
Elis "etu" Axelsson: Major contributor of current implemention and patcher of the first implementation
|
|
|
|
|
Sven-Hendrik "svenstaro" Haase: Major contributor of the first implementation
|
|
|
|
|
Jan Alexander "heftig" Steffens: Major contributor of the first implementation
|
|
|
|
|
Kyah "L-four" Rindlisbacher: Patched the first implementation
|
|
|
|
|
'''
|
2013-04-02 11:21:33 +02:00
|
|
|
|
from common import *
|
2013-04-02 11:26:38 +02:00
|
|
|
|
from argparser import *
|
2013-04-02 18:48:38 +02:00
|
|
|
|
from ponysay import *
|
2012-10-28 15:41:42 +01:00
|
|
|
|
|
2012-10-04 22:11:33 +02:00
|
|
|
|
|
|
|
|
|
|
2012-08-20 12:02:08 +02:00
|
|
|
|
'''
|
2013-04-04 14:09:18 +02:00
|
|
|
|
Start the program
|
2012-08-26 06:17:13 +02:00
|
|
|
|
'''
|
2012-10-28 15:59:29 +01:00
|
|
|
|
if __name__ == '__main__':
|
2013-04-04 14:09:18 +02:00
|
|
|
|
istool = sys.argv[0]
|
|
|
|
|
if os.sep in istool:
|
|
|
|
|
istool = istool[istool.rfind(os.sep) + 1:]
|
|
|
|
|
if os.extsep in istool:
|
|
|
|
|
istool = istool[:istool.find(os.extsep)]
|
|
|
|
|
istool = istool.endswith('-tool')
|
|
|
|
|
if istool:
|
2013-04-04 14:14:09 +02:00
|
|
|
|
from ponysaytool import * ## will start ponysay-tool
|
2013-04-04 14:09:18 +02:00
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
|
|
isthink = sys.argv[0]
|
|
|
|
|
if os.sep in isthink:
|
|
|
|
|
isthink = isthink[isthink.rfind(os.sep) + 1:]
|
|
|
|
|
if os.extsep in isthink:
|
|
|
|
|
isthink = isthink[:isthink.find(os.extsep)]
|
|
|
|
|
isthink = isthink.endswith('think')
|
2012-10-30 19:19:37 +01:00
|
|
|
|
|
2012-10-28 15:59:29 +01:00
|
|
|
|
usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m'
|
2012-10-30 21:32:56 +01:00
|
|
|
|
usage_common = '[-c] [-W\033[33mCOLUMN\033[39m] [-b\033[33mSTYLE\033[39m]'
|
2012-10-29 21:12:40 +01:00
|
|
|
|
usage_listhelp = '(-l | -L | -B | +l | +L | -A | + A | -v | -h)'
|
2012-10-30 21:32:56 +01:00
|
|
|
|
usage_file = '[-f\033[33mPONY\033[39m]* [[--] \033[33mmessage\033[39m]'
|
|
|
|
|
usage_xfile = '(+f\033[33mPONY\033[39m)* [[--] \033[33mmessage\033[39m]'
|
2013-04-03 17:03:42 +02:00
|
|
|
|
usage_afile = '(-F\033[33mPONY\033[39m)* [[--] \033[33mmessage\033[39m]'
|
2012-10-30 21:32:56 +01:00
|
|
|
|
usage_quote = '(-q\033[33mPONY\033[39m)*'
|
2012-10-28 15:59:29 +01:00
|
|
|
|
|
2013-04-03 20:00:57 +02:00
|
|
|
|
usage = ('%s %s' + 4 * '\n%s %s %s') % (usage_saythink, usage_listhelp,
|
|
|
|
|
usage_saythink, usage_common, usage_file,
|
|
|
|
|
usage_saythink, usage_common, usage_xfile,
|
|
|
|
|
usage_saythink, usage_common, usage_afile,
|
|
|
|
|
usage_saythink, usage_common, usage_quote)
|
2012-10-28 15:59:29 +01:00
|
|
|
|
|
|
|
|
|
usage = usage.replace('\033[', '\0')
|
|
|
|
|
for sym in ('[', ']', '(', ')', '|', '...', '*'):
|
|
|
|
|
usage = usage.replace(sym, '\033[2m' + sym + '\033[22m')
|
|
|
|
|
usage = usage.replace('\0', '\033[')
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
Argument parsing
|
|
|
|
|
'''
|
|
|
|
|
opts = ArgParser(program = 'ponythink' if isthink else 'ponysay',
|
|
|
|
|
description = 'cowsay reimplemention for ponies',
|
|
|
|
|
usage = usage,
|
|
|
|
|
longdescription =
|
2012-08-20 12:02:08 +02:00
|
|
|
|
'''Ponysay displays an image of a pony saying some text provided by the user.
|
|
|
|
|
If \033[4mmessage\033[24m is not provided, it accepts standard input. For an extensive
|
|
|
|
|
documentation run `info ponysay`, or for just a little more help than this
|
|
|
|
|
run `man ponysay`. Ponysay has so much more to offer than described here.''')
|
2012-10-28 15:59:29 +01:00
|
|
|
|
|
|
|
|
|
opts.add_argumentless(['--quoters'])
|
|
|
|
|
opts.add_argumentless(['--onelist'])
|
|
|
|
|
opts.add_argumentless(['++onelist'])
|
2013-04-01 20:35:12 +02:00
|
|
|
|
opts.add_argumentless(['--Onelist'])
|
2012-10-28 15:59:29 +01:00
|
|
|
|
|
|
|
|
|
opts.add_argumentless(['-X', '--256-colours', '--256colours', '--x-colours'])
|
|
|
|
|
opts.add_argumentless(['-V', '--tty-colours', '--ttycolours', '--vt-colours'])
|
|
|
|
|
opts.add_argumentless(['-K', '--kms-colours', '--kmscolours'])
|
|
|
|
|
|
2012-11-02 12:38:58 +01:00
|
|
|
|
opts.add_argumentless(['-i', '--info'])
|
|
|
|
|
opts.add_argumentless(['+i', '++info'])
|
|
|
|
|
opts.add_argumented( ['-r', '--restrict'], arg = 'RESTRICTION')
|
|
|
|
|
|
|
|
|
|
opts.add_argumented( ['+c', '--colour'], arg = 'COLOUR')
|
|
|
|
|
opts.add_argumented( ['--colour-bubble', '--colour-balloon'], arg = 'COLOUR')
|
|
|
|
|
opts.add_argumented( ['--colour-link'], arg = 'COLOUR')
|
|
|
|
|
opts.add_argumented( ['--colour-msg', '--colour-message'], arg = 'COLOUR')
|
|
|
|
|
opts.add_argumented( ['--colour-pony'], arg = 'COLOUR')
|
|
|
|
|
opts.add_argumented( ['--colour-wrap', '--colour-hyphen'], arg = 'COLOUR')
|
2012-10-28 15:59:29 +01:00
|
|
|
|
|
2013-04-01 20:35:12 +02:00
|
|
|
|
_F = ['--any-file', '--anyfile', '--any-pony', '--anypony']
|
|
|
|
|
__F = [_.replace("pony", "ponie") + 's' for _ in _F]
|
|
|
|
|
opts.add_argumentless(['-h', '--help'], help = 'Print this help message.')
|
|
|
|
|
opts.add_argumentless(['-v', '--version'], help = 'Print the version of the program.')
|
|
|
|
|
opts.add_argumentless(['-l', '--list'], help = 'List pony names.')
|
|
|
|
|
opts.add_argumentless(['-L', '--symlist', '--altlist'], help = 'List pony names with alternatives.')
|
|
|
|
|
opts.add_argumentless(['+l', '++list'], help = 'List non-MLP:FiM pony names.')
|
|
|
|
|
opts.add_argumentless(['+L', '++symlist', '++altlist'], help = 'List non-MLP:FiM pony names with alternatives.')
|
|
|
|
|
opts.add_argumentless(['-A', '--all'], help = 'List all pony names.')
|
|
|
|
|
opts.add_argumentless(['+A', '++all', '--symall', '--altall'], help = 'List all pony names with alternatives.')
|
|
|
|
|
opts.add_argumentless(['-B', '--bubblelist', '--balloonlist'], help = 'List balloon styles.')
|
|
|
|
|
opts.add_argumentless(['-c', '--compress', '--compact'], help = 'Compress messages.')
|
|
|
|
|
opts.add_argumentless(['-o', '--pony-only', '--ponyonly'], help = 'Print only the pony.')
|
|
|
|
|
opts.add_argumented( ['-W', '--wrap'], arg = 'COLUMN', help = 'Specify column where the message should be wrapped.')
|
|
|
|
|
opts.add_argumented( ['-b', '--bubble', '--balloon'], arg = 'STYLE', help = 'Select a balloon style.')
|
|
|
|
|
opts.add_argumented( ['-f', '--file', '--pony'], arg = 'PONY', help = 'Select a pony.\nEither a file name or a pony name.')
|
|
|
|
|
opts.add_argumented( ['+f', '++file', '++pony'], arg = 'PONY', help = 'Select a non-MLP:FiM pony.')
|
|
|
|
|
opts.add_argumented( ['-F'] + _F, arg = 'PONY', help = 'Select a pony, that can be a non-MLP:FiM pony.')
|
|
|
|
|
opts.add_argumented( ['-q', '--quote'], arg = 'PONY', help = 'Select a pony which will quote herself.')
|
|
|
|
|
opts.add_variadic( ['--f', '--files', '--ponies'], arg = 'PONY')
|
|
|
|
|
opts.add_variadic( ['++f', '++files', '++ponies'], arg = 'PONY')
|
|
|
|
|
opts.add_variadic( ['--F'] + __F, arg = 'PONY')
|
|
|
|
|
opts.add_variadic( ['--q', '--quotes'], arg = 'PONY')
|
2012-10-28 15:59:29 +01:00
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
Whether at least one unrecognised option was used
|
|
|
|
|
'''
|
|
|
|
|
unrecognised = not opts.parse()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Start
|
2012-10-30 01:31:17 +01:00
|
|
|
|
ponysay = Ponysay()
|
|
|
|
|
ponysay.unrecognised = unrecognised
|
|
|
|
|
ponysay.run(opts)
|