aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG10
-rw-r--r--manuals/manpage.04
-rw-r--r--manuals/ponysay.texinfo75
-rwxr-xr-xponysay.py55
4 files changed, 114 insertions, 30 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ed8663f..3e77fdf 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,13 @@
+Version 2.9
+
+ The option -q works like -f and -F, it takes one argument, and may be used multiple
+ times for more arguments.
+
+ The old option -q is renamed to --q.
+
+ The options --f and --F has been added.
+
+
Version 2.8
New ponies: airheart, bastionyorsets, peppermoon, shiningarmorwedding, starlight,
diff --git a/manuals/manpage.0 b/manuals/manpage.0
index 9627f62..5407e2c 100644
--- a/manuals/manpage.0
+++ b/manuals/manpage.0
@@ -76,8 +76,8 @@ multiple times, and one of the will be selected randomly.
.B \-q, \-\-quote [\fIname\fP...]
By using this option, a pony will be printed with quotes from her in My Little Pony:
Friendship is Magic. The pony will be selected randomly, unless at least one pony
-is added as an argument after \fI-q\fP. If one or more ponies are added after \fI-q\fP
-the pony will be selected randomly from that set of ponies.
+is added as an argument to \fI-q\fP. If one or more ponies are added as an argument
+to \fI-q\fP the pony will be selected randomly from that set of ponies.
.TP
.B \-W, \-\-wrap \fIcolumn\fP
The screen column where the message should be wrapped.
diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo
index 3bd4fe4..fc96d07 100644
--- a/manuals/ponysay.texinfo
+++ b/manuals/ponysay.texinfo
@@ -172,7 +172,7 @@ In versions earlier than version 2.0, the if the pony were a file name it had to
include a `@code{/}'. This is not longer required and any existing pony name
supersedes file names.
-@item -F
+@item -F PONY
@itemx ++file PONY
@itemx ++pony PONY
@opindex @option{-F}
@@ -181,6 +181,54 @@ supersedes file names.
Just as @option{-F}, but it uses extra (non-MLP:FiM) ponies instead of standard
(MLP:FiM) ponies
+@item -q PONY
+@itemx --quote PONY
+@opindex @option{-q}
+@opindex @option{--quote}
+@cindex quotes
+@cindex pony quotes
+By using this option, a pony will be printed with quotes from her in My Little Pony:
+Friendship is Magic. The pony will be selected randomly, unless at least one pony
+is added as an argument to @option{-q}. If one or more ponies are added as an argument
+to @option{-q}, the pony will be selected randomly from that set of ponies.
+This option requires the extension @command{ponyquotes4ponysay}, which is included
+by default since version 1.2.
+
+The argument can be a file name, but only if it ends with @file{.pony}.
+
+@item --f [PONY...]
+@itemx --files [PONY...]
+@itemx --ponies [PONY...]
+@opindex @option{--f}
+@opindex @option{--files}
+@opindex @option{--ponies}
+Variadic variant of @option{-f}, meaning that all arguments added after this one
+will parsed as an argument to this option. Additionally, those options are added
+to @option{-f}.
+
+@item --F [PONY...]
+@itemx ++files [PONY...]
+@itemx ++ponies [PONY...]
+@opindex @option{--F}
+@opindex @option{++files}
+@opindex @option{++ponies}
+Variadic variant of @option{-F}, meaning that all arguments added after this one
+will parsed as an argument to this option. Additionally, those options are added
+to @option{-F}.
+
+@item --q [PONY...]
+@itemx --quotes [PONY...]
+@opindex @option{--q}
+@opindex @option{--quotes}
+@cindex quotes
+@cindex pony quotes
+Variadic variant of @option{-q}, meaning that all arguments added after this one
+will parsed as an argument to this option. Additionally, those options are added
+to @option{-q}.
+
+An important feature of this options, is that you can but it in the end of the
+command line, without any argument to get a quote from any pony with a quote.
+
@item -b STYLE
@itemx --bubble STYLE
@itemx --balloon STYLE
@@ -192,19 +240,6 @@ balloon name printed by @option{ponysay -B}. This option can be used multiple
times to specify a set of styles from which one will be selected randomly. If no
balloon style is specified a fallback style will be used.
-@item -q [PONY...]
-@itemx --quote [PONY...]
-@opindex @option{-q}
-@opindex @option{--quote}
-By using this option, a pony will be printed with quotes from her in My Little Pony:
-Friendship is Magic. The pony will be selected randomly, unless at least one pony
-is added as an argument after @option{-q}. If one or more ponies are added after
-@option{-q}, the pony will be selected randomly from that set of ponies.
-This option requires the extension @command{ponyquotes4ponysay}, which is included
-by default since version 1.2.
-
-The argument can be a file name, but only if it ends with @file{.pony}.
-
@item -W COLUMN
@itemx --wrap COLUMN
@opindex @option{-W}
@@ -1947,6 +1982,18 @@ sequences.
@cindex versions
@cindex previous releases
+@heading Version 2.9
+@itemize @bullet
+@item
+The option @option{-q} works like @option{-f} and @option{-F}, it takes one argument, and
+may be used multiple times for more arguments.
+@item
+The old option @option{-q} is renamed to @option{--q}.
+@item
+The options @option{--f} and @option{--F} has been added.
+@end itemize
+
+
@heading Version 2.8
@itemize @bullet
@item
diff --git a/ponysay.py b/ponysay.py
index b7abe7f..a46576c 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -47,6 +47,14 @@ programs by default, report them to Princess Celestia so she can banish them to
def print(text = '', end = '\n'):
sys.stdout.buffer.write((str(text) + end).encode('utf-8'))
+'''
+stderr equivalent to print()
+
+@param text:str The text to print (empty string is default)
+@param end:str The appendix to the text to print (line breaking is default)
+'''
+def printerr(text = '', end = '\n'):
+ sys.stderr.buffer.write((str(text) + end).encode('utf-8'))
'''
Checks whether a text ends with a specific text, but has more
@@ -82,18 +90,23 @@ class Ponysay():
global extraponydirs
## Emulate termial capabilities
- if args.opts['-X'] is not None:
- linuxvt = False
- usekms = False
- elif args.opts['-V'] is not None:
- linuxvt = True
- usekms = False
- elif args.opts['-K'] is not None:
- linuxvt = True
- usekms = True
+ if args.opts['-X'] is not None: (linuxvt, usekms) = (False, False)
+ elif args.opts['-V'] is not None: (linuxvt, usekms) = (True, False)
+ elif args.opts['-K'] is not None: (linuxvt, usekms) = (True, True)
ponydirs = vtponydirs if linuxvt and not usekms else xponydirs
extraponydirs = extravtponydirs if linuxvt and not usekms else extraxponydirs
+ ## Variadic variants of -f, -F and -q
+ if args.opts['--f'] is not None:
+ if args.opts['-f'] is not None: args.opts['-f'] += args.opts['--f']
+ else: args.opts['-f'] = args.opts['--f']
+ if args.opts['--F'] is not None:
+ if args.opts['-F'] is not None: args.opts['-F'] += args.opts['--F']
+ else: args.opts['-F'] = args.opts['--F']
+ if args.opts['--q'] is not None:
+ if args.opts['-q'] is not None: args.opts['-q'] += args.opts['--q']
+ else: args.opts['-q'] = args.opts['--q']
+
## Run modes
if args.opts['-h'] is not None: args.help()
elif args.opts['--quoters'] is not None: self.quoters()
@@ -126,8 +139,19 @@ class Ponysay():
mode += '$/= $$\\= $'
## The stuff
- if args.opts['-q'] is not None: self.quote(args)
- else: self.print_pony(args)
+ if args.opts['-q'] is not None:
+ warn = (args.opts['-f'] is not None) or (args.opts['-F'] is not None)
+ if (len(args.opts['-q']) == 1) and ((args.opts['-q'][0] == '-f') or (args.opts['-q'][0] == '-F')):
+ warn = True
+ if args.opts['-q'][0] == '-f':
+ args.opts['-q'] = args.files
+ if args.opts['-f'] is not None:
+ args.opts['-q'] += args.opts['-f']
+ self.quote(args)
+ if warn:
+ printerr('-q cannot be used at the same time as -f or -F.')
+ else:
+ self.print_pony(args)
##############################################
@@ -2270,8 +2294,8 @@ usage_saythink = '\033[34;1m(ponysay | ponythink)\033[21;39m'
usage_common = '[-c] [-W\033[4mCOLUMN\033[24m] [-b\033[4mSTYLE\033[24m]'
usage_listhelp = '(-l | -L | -B | +l | +L | -v | -h)'
usage_file = '[-f\033[4mPONY\033[24m]* [[--] \033[4mmessage\033[24m]'
-usage_xfile = '[-F\033[4mPONY\033[24m]* [[--] \033[4mmessage\033[24m]'
-usage_quote = '-q [\033[4mPONY\033[24m*]'
+usage_xfile = '(-F\033[4mPONY\033[24m)* [[--] \033[4mmessage\033[24m]'
+usage_quote = '(-q \033[4mPONY\033[24m)*'
usage = '%s %s\n%s %s %s\n%s %s %s\n%s %s %s' % (usage_saythink, usage_listhelp,
usage_saythink, usage_common, usage_file,
@@ -2325,7 +2349,10 @@ opts.add_argumented( ['-W', '--wrap'], arg = 'COLUMN', help =
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_variadic( ['-q', '--quote'], arg = 'PONY', help = 'Select a ponies which will quote themself.')
+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( ['--q', '--quotes'], arg = 'PONY')
opts.parse()