everything needed for -F except for the logic itself

Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
Mattias Andrée 2013-04-01 20:35:12 +02:00
parent 4a2f35a7ae
commit e22b697ee5
4 changed files with 134 additions and 40 deletions

View file

@ -29,7 +29,7 @@ Version 3.0
fillycelestia and filliestia has been moved to extraponies. fillycelestia and filliestia has been moved to extraponies.
Renamed option -F to +f and option --F to ++f. Renamed option -F to +f and option --F to ++f, -F and --F has new definitions.
Environment variable 'PONYSAY_TYPO_LIMIT' has been added. Environment variable 'PONYSAY_TYPO_LIMIT' has been added.

View file

@ -22,24 +22,26 @@
) )
(multiple argumented (multiple argumented
((options -f --file --pony) (complete --file --pony) (arg PONY) (suggest pony-f) (files -f *.pony) (desc 'Specify the pony that should printed')) ((options -f --file --pony) (complete --file --pony) (arg PONY) (suggest pony-f) (files -f *.pony) (desc 'Specify the pony that should printed'))
((options +f ++file ++pony) (complete ++file ++pony) (arg PONY) (suggest pony+f) (files -f *.pony) (desc 'Specify the extrapony that should printed')) ((options +f ++file ++pony) (complete ++file ++pony) (arg PONY) (suggest pony+f) (files -f *.pony) (desc 'Specify the extrapony that should printed'))
((options -q --quote) (complete --quote) (arg PONY) (suggest pony-q) (files -f *.pony) (desc 'Specify the pony that should quote herself')) ((options -F --anyfile --any-file --anypony --any-pony) (complete --any-pony) (arg PONY) (suggest pony-F) (files -f *.pony) (desc 'Specify the [extra]pony that should printed'))
((options -b --bubble --balloon) (complete --balloon) (arg STYLE) (suggest balloon) (files -f (case (ponysay *.say) (ponyhink *.think))) (desc 'Specify message balloon style')) ((options -q --quote) (complete --quote) (arg PONY) (suggest pony-q) (files -f *.pony) (desc 'Specify the pony that should quote herself'))
((options -W --wrap) (complete --wrap) (arg COLUMN) (suggest wrap) (files -0) (desc 'Specify wrapping column')) ((options -b --bubble --balloon) (complete --balloon) (arg STYLE) (suggest balloon) (files -f (case (ponysay *.say) (ponyhink *.think))) (desc 'Specify message balloon style'))
((options +c --colour) (complete --colour) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the balloon, balloon link and message')) ((options -W --wrap) (complete --wrap) (arg COLUMN) (suggest wrap) (files -0) (desc 'Specify wrapping column'))
((options --colour-bubble --colour-balloon) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the balloon')) ((options +c --colour) (complete --colour) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the balloon, balloon link and message'))
((options --colour-link) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the balloon link')) ((options --colour-bubble --colour-balloon) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the balloon'))
((options --colour-msg --colour-message) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the message')) ((options --colour-link) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the balloon link'))
((options --colour-pony) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the pony (if uncoloured)')) ((options --colour-msg --colour-message) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the message'))
((options --colour-wrap --colour-hyphen) (arg ANSI-COLOUR) (files -0) (desc 'Specify addition colour of wrapping hyphen')) ((options --colour-pony) (arg ANSI-COLOUR) (files -0) (desc 'Specify colour of the pony (if uncoloured)'))
((options --colour-wrap --colour-hyphen) (arg ANSI-COLOUR) (files -0) (desc 'Specify addition colour of wrapping hyphen'))
((options -r --restrict) (complete --restrict) (arg RESTRICTION) (suggest -r) (files -0) (desc 'Restrict randomly selected ponies')) ((options -r --restrict) (complete --restrict) (arg RESTRICTION) (suggest -r) (files -0) (desc 'Restrict randomly selected ponies'))
) )
(variadic (options --f --files --ponies) (bind -f) (desc 'Specify the ponies that may be printed')) (variadic (options --f --files --ponies) (bind -f) (desc 'Specify the ponies that may be printed'))
(variadic (options ++f ++files ++ponies) (bind +f) (desc 'Specify the extraponies that may be printed')) (variadic (options ++f ++files ++ponies) (bind +f) (desc 'Specify the extraponies that may be printed'))
(variadic (options --q --quotes) (bind -q) (desc 'Specify the pony that may quote themself')) (variadic (options --F --anyfiles --any-files --anyponies --any-ponies) (bind -F) (desc 'Specify the [extra]ponies that may be printed'))
(variadic (options --q --quotes) (bind -q) (desc 'Specify the pony that may quote themself'))
(suggestion message (verbatim MESSAGE) (suggestion message (verbatim MESSAGE)
) )
@ -49,6 +51,9 @@
(suggestion pony+f (exec "'/usr/bin/ponysay'" ++onelist) (suggestion pony+f (exec "'/usr/bin/ponysay'" ++onelist)
(no-exec ls "'/usr/share/ponysay/extraponies'" .pony) (no-exec ls "'/usr/share/ponysay/extraponies'" .pony)
) )
(suggestion pony-F (exec "'/usr/bin/ponysay'" --Onelist)
(no-exec ls "'/usr/share/ponysay/extraponies'" .pony)
)
(suggestion pony-q (exec "'/usr/bin/ponysay'" --quoters) (suggestion pony-q (exec "'/usr/bin/ponysay'" --quoters)
(no-exec ls "'/usr/share/ponysay/ponies'" .pony) (no-exec ls "'/usr/share/ponysay/ponies'" .pony)
) )

View file

@ -183,6 +183,18 @@ supersedes file names.
Just as @option{+f}, but it uses extra (non-MLP:FiM) ponies instead of standard Just as @option{+f}, but it uses extra (non-MLP:FiM) ponies instead of standard
(MLP:FiM) ponies (MLP:FiM) ponies
@item -F PONY
@itemx --any-file PONY
@itemx --anyfile PONY
@itemx --any-pony PONY
@itemx --anypony PONY
@opindex @option{-F}
@opindex @option{--any-file}
@opindex @option{--anyfile}
@opindex @option{--any-pony}
@opindex @option{--anypony}
This option combines @option{-f} and @option{+f}.
@item -q PONY @item -q PONY
@itemx --quote PONY @itemx --quote PONY
@opindex @option{-q} @opindex @option{-q}
@ -223,6 +235,18 @@ command line, without any argument to get a random non-MLP:FiM pony. However,
altough it is not nice, since version 3.0, @option{+f} can also be unargumented altough it is not nice, since version 3.0, @option{+f} can also be unargumented
if at the end of the command line. if at the end of the command line.
@item --F [PONY...]
@itemx --any-files [PONY...]
@itemx --anyfiles [PONY...]
@itemx --any-ponies [PONY...]
@itemx --anyponies [PONY...]
@opindex @option{--F}
@opindex @option{--any-file}
@opindex @option{--anyfile}
@opindex @option{--any-pony}
@opindex @option{--anypony}
This option combines @option{--f} and @option{++f}.
@item --q [PONY...] @item --q [PONY...]
@itemx --quotes [PONY...] @itemx --quotes [PONY...]
@opindex @option{--q} @opindex @option{--q}
@ -2518,15 +2542,17 @@ use Python 3, which as been accomplished in version 2.1.
@cindex shell, auto-completion @cindex shell, auto-completion
@opindex @option{--onelist} @opindex @option{--onelist}
@opindex @option{++onelist} @opindex @option{++onelist}
@opindex @option{--Onelist}
@opindex @option{--quoters} @opindex @option{--quoters}
@pindex @command{auto-auto-complete} @pindex @command{auto-auto-complete}
To make it easier to write auto-completion for shells, @command{ponysay} supports To make it easier to write auto-completion for shells, @command{ponysay} supports
the two options @option{--onelist}, @option{++onelist} and @option{--quoters}, the options @option{--onelist}, @option{++onelist}, @option{--Onelist} and
which has no short versions. To make it even easier we use @command{auto-auto-complete} @option{--quoters}, which has no short versions. To make it even easier we use
(@url{https://www.github.com/maandree/auto-auto-complete}) to generate auto-completion @command{auto-auto-complete} (@url{https://www.github.com/maandree/auto-auto-complete})
scripts, currently it supports @command{bash}, @command{fish} and @command{zsh}, to generate auto-completion scripts, currently it supports @command{bash},
the built system uses that program to generate completion for each shell. @command{fish} and @command{zsh}, the built system uses that program to generate
completion for each shell.
Executing @command{ponysay --onelist} will list every available standard (MLP:FiM) Executing @command{ponysay --onelist} will list every available standard (MLP:FiM)
pony, independent of where it is located, the output is a sorted and consists only pony, independent of where it is located, the output is a sorted and consists only
@ -2536,6 +2562,10 @@ Executing @command{ponysay ++onelist} will list every available extra (non-MLP:F
pony, independent of where it is located, the output is a sorted and consists only pony, independent of where it is located, the output is a sorted and consists only
of one pony per line. of one pony per line.
Executing @command{ponysay --Onelist} will list every available standard pony as
well as extra pony, independent of where it is located, the output is a sorted and
consists only of one pony per line.
@command{ponysay --quoters} work just as @command{ponysay --onelist}, excepts @command{ponysay --quoters} work just as @command{ponysay --onelist}, excepts
it limits the ponies to those that have quotes. Ponies that have quotes, it limits the ponies to those that have quotes. Ponies that have quotes,
but does not exist, i.e. does not have a .pony-file, are not listed. but does not exist, i.e. does not have a .pony-file, are not listed.
@ -2938,7 +2968,7 @@ New extraponies: @file{donutpony}, @file{gleamingshield}, @file{hastelle}, @file
@item @item
@file{ironwillwalk} has been renamed to @file{ironwillwalk} (need a version named as master) @file{ironwillwalk} has been renamed to @file{ironwillwalk} (need a version named as master)
@item @item
Renamed option @option{-F} to @option{+f} and option @option{--F} to @option{++f}. Renamed option @option{-F} to @option{+f} and option @option{--F} to @option{++f}, @option{-F} and @option{--F} has new definitions.
@item @item
Environment variable @env{PONYSAY_TYPO_LIMIT} has been added. Environment variable @env{PONYSAY_TYPO_LIMIT} has been added.
@item @item

View file

@ -312,10 +312,15 @@ class Ponysay():
if args.opts[sl] is not None: args.opts[sl] += args.opts[ssl] if args.opts[sl] is not None: args.opts[sl] += args.opts[ssl]
else: args.opts[sl] = args.opts[ssl] else: args.opts[sl] = args.opts[ssl]
## Save whether standard or extra ponies are used
self.usingstandard = (args.opts['-f'] is not None) or (args.opts['-F'] is not None) or (args.opts['-q'] is not None) or (args.opts['-Q'] is not None)
self.usingextra = (args.opts['+f'] is not None) or (args.opts['-F'] is not None) or (args.opts['+q'] is not None) or (args.opts['-Q'] is not None)
## Run modes ## Run modes
if args.opts['-h'] is not None: args.help() if args.opts['-h'] is not None: args.help()
elif args.opts['--quoters'] is not None: self.quoters() elif args.opts['--quoters'] is not None: self.quoters()
elif args.opts['--onelist'] is not None: self.onelist() elif args.opts['--onelist'] is not None: self.onelist()
elif args.opts['--Onelist'] is not None: self.fullonelist()
elif args.opts['-v'] is not None: self.version() elif args.opts['-v'] is not None: self.version()
elif args.opts['-l'] is not None: self.list() elif args.opts['-l'] is not None: self.list()
elif args.opts['-L'] is not None: self.linklist() elif args.opts['-L'] is not None: self.linklist()
@ -619,6 +624,10 @@ class Ponysay():
if (len(alternatives) > 0) and (dist <= limit): if (len(alternatives) > 0) and (dist <= limit):
return self.__getponypath(alternatives, True) return self.__getponypath(alternatives, True)
sys.stderr.write('I have never heard of anypony named %s\n' % (pony)); sys.stderr.write('I have never heard of anypony named %s\n' % (pony));
if not self.usingstandard:
sys.stderr.write('Use -f/-q or -F if it a MLP:FiM pony');
if not self.usingexta:
sys.stderr.write('Have you tested +f or -F?');
exit(1) exit(1)
else: else:
return ponies[pony] return ponies[pony]
@ -986,6 +995,51 @@ class Ponysay():
print(pony) print(pony)
'''
Lists the available ponies on one column without anything bold or otherwise formated, both standard ponies and extra ponies
'''
def fullonelist(self):
## Get all pony files
_ponies = []
for ponydir in self.ponydirs: # Loop ponydirs
_ponies += os.listdir(ponydir)
## Remove .pony from all files and skip those that does not have .pony
ponies = []
for pony in _ponies:
if endswith(pony, '.pony'):
ponies.append(pony[:-5])
## UCS:ise
self.__ucsise(ponies)
## Swap to extra ponies
self.__extraponies()
## Get all pony files
_ponies = []
for ponydir in self.ponydirs: # Loop ponydirs
_ponies += os.listdir(ponydir)
## Remove .pony from all files and skip those that does not have .pony
xponies = []
for pony in _ponies:
if endswith(pony, '.pony'):
xponies.append(pony[:-5])
## UCS:ise
self.__ucsise(xponies)
## Print each one on a seperate line, but skip duplicates
last = ''
ponies += xponies
ponies.sort()
for pony in ponies:
if not pony == last:
last = pony
print(pony)
##################### #####################
## Balloon methods ## ## Balloon methods ##
##################### #####################
@ -2792,6 +2846,7 @@ run `man ponysay`. Ponysay has so much more to offer than described here.''')
opts.add_argumentless(['--quoters']) opts.add_argumentless(['--quoters'])
opts.add_argumentless(['--onelist']) opts.add_argumentless(['--onelist'])
opts.add_argumentless(['++onelist']) opts.add_argumentless(['++onelist'])
opts.add_argumentless(['--Onelist'])
opts.add_argumentless(['-X', '--256-colours', '--256colours', '--x-colours']) opts.add_argumentless(['-X', '--256-colours', '--256colours', '--x-colours'])
opts.add_argumentless(['-V', '--tty-colours', '--ttycolours', '--vt-colours']) opts.add_argumentless(['-V', '--tty-colours', '--ttycolours', '--vt-colours'])
@ -2808,25 +2863,29 @@ run `man ponysay`. Ponysay has so much more to offer than described here.''')
opts.add_argumented( ['--colour-pony'], arg = 'COLOUR') opts.add_argumented( ['--colour-pony'], arg = 'COLOUR')
opts.add_argumented( ['--colour-wrap', '--colour-hyphen'], arg = 'COLOUR') opts.add_argumented( ['--colour-wrap', '--colour-hyphen'], arg = 'COLOUR')
opts.add_argumentless(['-h', '--help'], help = 'Print this help message.') _F = ['--any-file', '--anyfile', '--any-pony', '--anypony']
opts.add_argumentless(['-v', '--version'], help = 'Print the version of the program.') __F = [_.replace("pony", "ponie") + 's' for _ in _F]
opts.add_argumentless(['-l', '--list'], help = 'List pony names.') opts.add_argumentless(['-h', '--help'], help = 'Print this help message.')
opts.add_argumentless(['-L', '--symlist', '--altlist'], help = 'List pony names with alternatives.') opts.add_argumentless(['-v', '--version'], help = 'Print the version of the program.')
opts.add_argumentless(['+l', '++list'], help = 'List non-MLP:FiM pony names.') opts.add_argumentless(['-l', '--list'], help = 'List pony names.')
opts.add_argumentless(['+L', '++symlist', '++altlist'], help = 'List non-MLP:FiM pony names with alternatives.') opts.add_argumentless(['-L', '--symlist', '--altlist'], help = 'List pony names with alternatives.')
opts.add_argumentless(['-A', '--all'], help = 'List all pony names.') opts.add_argumentless(['+l', '++list'], help = 'List non-MLP:FiM pony names.')
opts.add_argumentless(['+A', '++all', '--symall', '--altall'], help = 'List all pony names with alternatives.') opts.add_argumentless(['+L', '++symlist', '++altlist'], help = 'List non-MLP:FiM pony names with alternatives.')
opts.add_argumentless(['-B', '--bubblelist', '--balloonlist'], help = 'List balloon styles.') opts.add_argumentless(['-A', '--all'], help = 'List all pony names.')
opts.add_argumentless(['-c', '--compress', '--compact'], help = 'Compress messages.') opts.add_argumentless(['+A', '++all', '--symall', '--altall'], help = 'List all pony names with alternatives.')
opts.add_argumentless(['-o', '--pony-only', '--ponyonly'], help = 'Print only the pony.') opts.add_argumentless(['-B', '--bubblelist', '--balloonlist'], help = 'List balloon styles.')
opts.add_argumented( ['-W', '--wrap'], arg = 'COLUMN', help = 'Specify column where the message should be wrapped.') opts.add_argumentless(['-c', '--compress', '--compact'], help = 'Compress messages.')
opts.add_argumented( ['-b', '--bubble', '--balloon'], arg = 'STYLE', help = 'Select a balloon style.') opts.add_argumentless(['-o', '--pony-only', '--ponyonly'], help = 'Print only the pony.')
opts.add_argumented( ['-f', '--file', '--pony'], arg = 'PONY', help = 'Select a pony.\nEither a file name or a pony name.') opts.add_argumented( ['-W', '--wrap'], arg = 'COLUMN', help = 'Specify column where the message should be wrapped.')
opts.add_argumented( ['+f', '++file', '++pony'], arg = 'PONY', help = 'Select a non-MLP:FiM pony.') opts.add_argumented( ['-b', '--bubble', '--balloon'], arg = 'STYLE', help = 'Select a balloon style.')
opts.add_argumented( ['-q', '--quote'], arg = 'PONY', help = 'Select a pony which will quote herself.') opts.add_argumented( ['-f', '--file', '--pony'], arg = 'PONY', help = 'Select a pony.\nEither a file name or a pony name.')
opts.add_variadic( ['--f', '--files', '--ponies'], arg = 'PONY') opts.add_argumented( ['+f', '++file', '++pony'], arg = 'PONY', help = 'Select a non-MLP:FiM pony.')
opts.add_variadic( ['++f', '++files', '++ponies'], arg = 'PONY') opts.add_argumented( ['-F'] + _F, arg = 'PONY', help = 'Select a pony, that can be a non-MLP:FiM pony.')
opts.add_variadic( ['--q', '--quotes'], arg = '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')
''' '''
Whether at least one unrecognised option was used Whether at least one unrecognised option was used