diff options
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | completion/bash-completion.sh | 8 | ||||
-rw-r--r-- | completion/fish-completion.fish | 5 | ||||
-rw-r--r-- | completion/zsh-completion.zsh | 5 | ||||
-rwxr-xr-x | configure | 37 | ||||
-rw-r--r-- | extraponies/info | 3 | ||||
-rw-r--r-- | extrattyponies/info | 3 | ||||
-rw-r--r-- | manuals/ponysay.texinfo | 66 | ||||
-rwxr-xr-x | ponysay | 66 |
9 files changed, 165 insertions, 31 deletions
@@ -15,6 +15,9 @@ Version 2.3 Pony symlink added: pinkieoink → oinkoinkoink + Support for non-MLP:FiM ponies (known as extraponies), + although the directory is currently empty. + Version 2.2 diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh index 72cafcb..62e1d40 100644 --- a/completion/bash-completion.sh +++ b/completion/bash-completion.sh @@ -5,13 +5,17 @@ _ponysay() local cur prev words cword _init_completion -n = || return - options='--version --help --list --altlist --pony --wrap --quote --balloonlist --balloon' + options='--version --help --list --altlist --pony --wrap --quote --balloonlist --balloon --file ++file ++pony ++list ++altlist' COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) - if [ $prev = "-f" ] || [ $prev = "--pony" ]; then + if [ $prev = "-f" ] || [ $prev = "--pony" ] || [ $prev = "--file" ]; then ponies=$('/usr/bin/ponysay' --onelist) COMPREPLY=( $( compgen -W "$ponies" -- "$cur" ) ) + elif [ $prev = "-F" ] || [ $prev = "++pony" ] || [ $prev = "++file" ]; then + extraponies=$('/usr/bin/ponysay' ++onelist) + COMPREPLY=( $( compgen -W "$extraponies" -- "$cur" ) ) + elif [ $prev = "-q" ] || [ $prev = "--quote" ]; then quoters=$('/usr/bin/ponysay' --quoters) COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) ) diff --git a/completion/fish-completion.fish b/completion/fish-completion.fish index c211982..c29fff2 100644 --- a/completion/fish-completion.fish +++ b/completion/fish-completion.fish @@ -4,21 +4,26 @@ # Author: Elis Axelsson <etu AT elis DOT nu> set -g ponies ('/usr/bin/ponysay' --onelist) +set -g xponies ('/usr/bin/ponysay' ++onelist) set -g quoters ('/usr/bin/ponysay' --quoters) set -g balloons ('/usr/bin/ponysay' --balloonlist) +## TODO: update with options [see info manual]: +l +L ++list ++altlist ++file --file ++pony complete --command ponysay --short-option h --long-option help --description 'help of ponysay' complete --command ponysay --short-option v --long-option version --description 'version of ponysay' complete --command ponysay --short-option l --long-option list --description 'list pony names' complete --command ponysay --short-option L --long-option altlist --description 'list pony names with alternatives' complete --command ponysay --short-option B --long-option balloonlist --description 'list balloon style names' complete --command ponysay --short-option f --long-option pony --arguments "$ponies" --description 'pony' +complete --command ponysay --short-option F --arguments "$xponies" --description 'extra pony' complete --command ponysay --short-option q --long-option quote --arguments "$quoters" --description 'pony' complete --command ponysay --short-option b --long-option balloon --arguments "$balloons" --description 'balloon style' complete --command ponysay --short-option W --long-option wrap --arguments 'Integer' --description 'specify the column when the message should be wrapped' complete --command ponysay --arguments 'MESSAGE' + set -e ponies +set -e xponies set -e quoters set -e balloons diff --git a/completion/zsh-completion.zsh b/completion/zsh-completion.zsh index c19604d..9d417ec 100644 --- a/completion/zsh-completion.zsh +++ b/completion/zsh-completion.zsh @@ -4,8 +4,11 @@ _shortopts=( '-h[Show this help and exit]' '-l[list pony names]' '-L[list pony names with alternatives]' + '+l[list extra pony names]' + '+L[list extra pony names with alternatives]' '-B[list balloon style names]' - '-f[Select a pony (either a file name or a pony name]: :_path_files -W '/usr/share/ponysay/ponies' -g "*(\:r)"' + '-f[Select a pony (either a file name or a pony name)]: :_path_files -W '/usr/share/ponysay/ponies' -g "*(\:r)"' + '-F[Select a extra pony]: :_path_files -W '/usr/share/ponysay/extraponies' -g "*(\:r)"' '-q[Select ponies for MLP:FiM quotes]' '-b[Selecy a balloon style]' '-W[The screen column where the message should be wrapped]' @@ -6,7 +6,7 @@ INFODESC=\''My Little Ponies for your terminal'\' SHELL='bash' completions='completion/bash-completion.sh completion/fish-completion.fish completion/zsh-completion.zsh' -shareDirs='ponies ttyponies quotes balloons' +shareDirs='ponies ttyponies quotes balloons extraponies extrattyponies' manFiles='manuals/manpage.6 manuals/manpage.es.6' licenseFiles='COPYING' @@ -224,7 +224,7 @@ function makeMakefile() echo -en '\t' ; echo 'mkdir -p "$(INSTALLDIR)/share/ponysay/"' for dir in $shareDirs; do echo -en '\t' ; echo 'mkdir -p "$(INSTALLDIR)/share/ponysay/'"$dir"'"' - echo -en '\t' ; echo 'cp -P "'"$dir"'/"*.* "$(INSTALLDIR)/share/ponysay/'"$dir"'/"' + echo -en '\t' ; echo 'cp -P "'"$dir"'/"* "$(INSTALLDIR)/share/ponysay/'"$dir"'/"' done echo echo -en '\t' ; echo 'mkdir -p "$(INSTALLDIR)/bin/"' @@ -360,15 +360,30 @@ EOF ttyponies: mkdir -p "ttyponies" - for pony in \$\$(ls --color=no "ponies/"); do \\ - echo "building ttypony: \$\$pony" ;\\ - if [ "\`readlink "ponies/\$\$pony"\`" = '' ]; then \\ - ponysay2ttyponysay < "ponies/\$\$pony" | tty2colourfultty -c 1 > "ttyponies/\$\$pony" ;\\ - git add "ttyponies/\$\$pony" ;\\ - else \\ - ln -sf \`readlink "ponies/\$\$pony"\` "ttyponies/\$\$pony" ;\\ - git add "ttyponies/\$\$pony" ;\\ - fi ;\\ + for pony in \$\$(ls --color=no "ponies/"); do \\ + if [ 1 "\$\$pony" = '.info' ]; then \\ + echo "building ttypony: \$\$pony" ;\\ + if [ "\`readlink "ponies/\$\$pony"\`" = '' ]; then \\ + ponysay2ttyponysay < "ponies/\$\$pony" | tty2colourfultty -c 1 > "ttyponies/\$\$pony" ;\\ + git add "ttyponies/\$\$pony" ;\\ + else \\ + ln -sf \`readlink "ponies/\$\$pony"\` "ttyponies/\$\$pony" ;\\ + git add "ttyponies/\$\$pony" ;\\ + fi ;\\ + fi ;\\ + done + mkdir -p "extrattyponies" + for pony in \$\$(ls --color=no "extraponies/"); do \\ + if [ 1 "\$\$pony" = '.info' ]; then \\ + echo "building extrattypony: \$\$pony" ;\\ + if [ "\`readlink "extraponies/\$\$pony"\`" = '' ]; then \\ + ponysay2ttyponysay < "extraponies/\$\$pony" | tty2colourfultty -c 1 > "extrattyponies/\$\$pony" ;\\ + git add "extrattyponies/\$\$pony" ;\\ + else \\ + ln -sf \`readlink "extraponies/\$\$pony"\` "extrattyponies/\$\$pony" ;\\ + git add "extrattyponies/\$\$pony" ;\\ + fi ;\\ + fi ;\\ done pdfmanual: diff --git a/extraponies/info b/extraponies/info new file mode 100644 index 0000000..12d5bea --- /dev/null +++ b/extraponies/info @@ -0,0 +1,3 @@ +Dummy file for this directory as it is otherwise empty. + +Non-MLP:FiM ponies should be placed here. diff --git a/extrattyponies/info b/extrattyponies/info new file mode 100644 index 0000000..333e827 --- /dev/null +++ b/extrattyponies/info @@ -0,0 +1,3 @@ +Dummy file for this directory as it is otherwise empty. + +Non-MLP:FiM ttyponies should be placed here. diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo index f6735fa..c0d3633 100644 --- a/manuals/ponysay.texinfo +++ b/manuals/ponysay.texinfo @@ -154,6 +154,15 @@ 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 +@itemx ++file PONY +@itemx ++pony PONY +@cindex @command{-F} +@cindex @command{++file} +@cindex @command{++pony} +Just as @command{-F}, but it uses extra (non-MLP:FiM) ponies instead of +standard (MLP:FiM) ponies + @item -b STYLE @itemx --bubble STYLE @itemx --balloon STYLE @@ -206,7 +215,7 @@ is installed the ponies which have quotes, i.e. can be used with the (depending on the terminal.) @item -L -@itemx --linklist +@itemx --altlist @cindex @command{-L} @cindex @command{--altlist} Lists all installed ponies. If the extension @command{ponyquotes4ponysay} @@ -216,6 +225,20 @@ is installed the ponies which have quotes, i.e. can be used with the printing alternative names (symbolic links) inside brackets after their target ponies. +@item +l +@itemx ++list +@cindex @command{+l} +@cindex @command{++list} +Just as @command{-l}, but it lists extra (non-MLP:FiM) ponies instead of +standard (MLP:FiM) ponies + +@item +L +@itemx ++altlist +@cindex @command{+L} +@cindex @command{++altlist} +Just as @command{-L}, but it lists extra (non-MLP:FiM) ponies instead of +standard (MLP:FiM) ponies + @item -B @itemx --balloonlist @cindex @command{-B} @@ -1062,14 +1085,19 @@ and only use Python 3, which as been accomplished in version 2.1. @cindex auto-completion, inner workings @cindex shell, auto-completion @cindex @command{--onelist} +@cindex @command{++onelist} @cindex @command{--quoters} To make it easier to write auto-completion for shells, @command{ponysay} supports -the two options @command{--onelist} and @command{--quoters}, which has not short -versions. +the two options @command{--onelist}, @command{++onelist} and @command{--quoters}, +which has nt short versions. -Executing @command{ponysay --onelist} will list every available pony, -independent of where it is located, the output is a sorted and consists only +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 +of one pony per line. + +Executing @command{ponysay ++onelist} will list every available extra (non-MLP:FiM) +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 @@ -1229,13 +1257,20 @@ and as always regular files.) @item Support cowsay style message compression. @item -or @command{ponythink} Pony symlink added: @itemize @bullet @item @code{pinkieoink} → @code{oinkoinkoink} @end itemize +@item +Support for non-MLP:FiM ponies (known as extraponies), although the directory +is currently empty. +@c BEGIN the following is too descriptive for the plain/text change log +This is implemented with the options @code{-F}, @code{+l}, and @code{+L} +corresponding to @code{-f}, @code{-l}, and @code{-L}. +@c END @end itemize + @heading Version 2.2 @itemize @bullet @@ -1251,10 +1286,12 @@ Support custom balloon styles using the option @code{-b}, @code{-B} will list all available. This list depends on whether you are invoking @command{ponysay} @end itemize + @heading Version 2.1.1 Nothing worth mention. + @heading Version 2.1 @itemize @bullet @@ -1278,6 +1315,7 @@ minimum size of balloon. @c END @end itemize + @heading Version 2.0 @itemize @bullet @@ -1289,12 +1327,14 @@ All Perl scripts and almost all Bash are reimplemented in one Python 3 script. kmsponies4ponysay is included. @end itemize + @heading Version 1.4.1 @itemize @bullet @item Code is repaired and more portable. @end itemize + @heading Version 1.4 @itemize @bullet @@ -1304,6 +1344,7 @@ Make file is improved. @b{Note}: Identifies itself as version 1.3 + @heading Version 1.3 @itemize @bullet @@ -1320,6 +1361,7 @@ Pony symlink added: the default value is @code{/usr} @end itemize + @heading Version 1.2 @itemize @bullet @@ -1347,6 +1389,7 @@ file names including spaces.) @b{Note}: Identifies itself as version 1.1 + @heading Version 1.1 @itemize @bullet @@ -1395,6 +1438,7 @@ Support for extension: ponyquotes4ponysay. Accepts arbitrary spaces in @command{-f} argument. @end itemize + @heading Version 1.0 @itemize @bullet @@ -1425,6 +1469,7 @@ Improved TTY support: ponies have low colours resolution, instead of monochrome, when the high colour resolution is not available. @end itemize + @heading Version 0.10 @itemize @bullet @@ -1456,6 +1501,7 @@ Environment variables added: @code{PONYSAY_FULL_WIDTH}, @code{PONYSAY_SHELL_LINE @code{PONYSAY_TRUNCATE_HEIGHT}, @code{PONYSAY_BOTTOM}. @end itemize + @heading Version 0.9 @itemize @bullet @@ -1475,6 +1521,7 @@ Support for TTY (Linux VT). @code{sparkler}, @code{violet}. @end itemize + @heading Version 0.8 @itemize @bullet @@ -1504,6 +1551,7 @@ Support for TTY (Linux VT). @b{Note}: Identifies itself as version 0.7 + @heading Version 0.7 @itemize @bullet @@ -1514,6 +1562,7 @@ Support for TTY (Linux VT). Support for listing ponies with @command{-l} option. @end itemize + @heading Version 0.6 @itemize @bullet @@ -1526,6 +1575,7 @@ Dropping usage of utility @command{which}, using @command{hash} instead. @b{Note}: Identifies itself as version 0.5 + @heading Version 0.5 @itemize @bullet @@ -1533,6 +1583,7 @@ Dropping usage of utility @command{which}, using @command{hash} instead. Using utility @command{which} to determine existence of @command{cowsay}. @end itemize + @heading Version 0.4 @itemize @bullet @@ -1548,6 +1599,7 @@ Select random pony if not specified. @command{-f} supports file names, and not only pony names. @end itemize + @heading Version 0.3 @itemize @bullet @@ -1555,6 +1607,7 @@ Select random pony if not specified. Fixed use of @code{.pony} files. @end itemize + @heading Version 0.2 @itemize @bullet @@ -1569,6 +1622,7 @@ Pony files end with @code{.pony} instead of @code{.cow}. @command{-h} prints proper help. @end itemize + @heading Version 0.1 First release. @@ -55,7 +55,11 @@ class Ponysay(): elif args.opts['-l'] is not None: self.list() elif args.opts['-L'] is not None: self.linklist() elif args.opts['-B'] is not None: self.balloonlist() + elif args.opts['++onelist'] is not None: self.__extraponies(); self.onelist() + elif args.opts['+l'] is not None: self.__extraponies(); self.list() + elif args.opts['+L'] is not None: self.__extraponies(); self.linklist() else: + self.__extraponies(args) self.__bestpony(args) self.__ucsremap(args) if args.opts['-q'] is not None: self.quote(args) @@ -63,10 +67,21 @@ class Ponysay(): ## - ## Auxiliary methods + ## Methods that run before the mane methods ## ''' + Use extra ponies + ''' + def __extraponies(self, args = None): + if args is None: + ponydirs[:] = extraponydirs + elif args.opts['-F'] is not None: + args.opts['-f'] = args.opts['-F'] + ponydirs[:] = extraponydirs + + + ''' Use best.pony if nothing else is set ''' def __bestpony(self, args): @@ -118,6 +133,10 @@ class Ponysay(): args.opts[flag][i] = map[args.opts[flag][i]] + ## + ## Auxiliary methods + ## + ''' Apply USC:ise pony names according to UCS settings ''' @@ -263,8 +282,6 @@ class Ponysay(): quoters = self.__quoters() for ponydir in ponydirs: # Loop ponydirs - print('\033[1mponies located in ' + ponydir + '\033[21m') - _ponies = os.listdir(ponydir) ponies = [] for pony in _ponies: @@ -273,6 +290,10 @@ class Ponysay(): self.__ucsise(ponies) ponies.sort() + if len(ponies) == 0: + continue + print('\033[1mponies located in ' + ponydir + '\033[21m') + width = UCS.dispLen(max(ponies, key = UCS.dispLen)) + 2 # Get the longest ponyfilename lenght + 2 spaces x = 0 @@ -295,13 +316,16 @@ class Ponysay(): quoters = self.__quoters() for ponydir in ponydirs: # Loop ponydirs - print('\033[1mponies located in ' + ponydir + '\033[21m') - _ponies = os.listdir(ponydir) ponies = [] for pony in _ponies: if (len(pony) > 5) and (pony[-5:] == '.pony'): ponies.append(pony[:-5]) + + if len(ponies) == 0: + continue + print('\033[1mponies located in ' + ponydir + '\033[21m') + pseudolinkmap = {} self.__ucsise(ponies, pseudolinkmap) ##TODO pairs = [] @@ -1597,6 +1621,12 @@ pipelineerr = not sys.stderr.isatty() ''' +Whether KMS is used +''' +usekms = Ponysay.isUsingKMS() + + +''' Root share/ directories ''' sharedirs = [] @@ -1607,18 +1637,28 @@ for sharedir in _sharedirs: ''' -The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY) +The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY) and not with KMS ''' ponydirs = [] -_kms = Ponysay.isUsingKMS() -if linuxvt and not _kms: _ponydirs = [d + 'ttyponies/' for d in sharedirs] -else: _ponydirs = [d + 'ponies/' for d in sharedirs] +if linuxvt and not usekms: _ponydirs = [d + 'ttyponies/' for d in sharedirs] +else: _ponydirs = [d + 'ponies/' for d in sharedirs] for ponydir in _ponydirs: if os.path.isdir(ponydir): ponydirs.append(ponydir) ''' +The directories where pony files are stored, extrattyponies/ are used if the terminal is Linux VT (also known as TTY) and not with KMS +''' +extraponydirs = [] +if linuxvt and not usekms: _extraponydirs = [d + 'extrattyponies/' for d in sharedirs] +else: _extraponydirs = [d + 'extraponies/' for d in sharedirs] +for extraponydir in _extraponydirs: + if os.path.isdir(extraponydir): + extraponydirs.append(extraponydir) + + +''' The directories where quotes files are stored ''' quotedirs = [] @@ -1640,8 +1680,8 @@ for balloondir in _balloondirs: 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 | -v | -h)' -usage_file = '[-f \033[4mPONY\033[24m]... ([--] \033[4mmessage\033[24m | <<<\033[4mmessage\033[24m)' +usage_listhelp = '(-l | -L | -B | +l | +L | -v | -h)' +usage_file = '[(-f | -F) \033[4mPONY\033[24m]... ([--] \033[4mmessage\033[24m | <<<\033[4mmessage\033[24m)' usage_quote = '-q [\033[4mPONY\033[24m...]' usage = '%s %s\n%s %s %s\n%s %s %s' % (usage_saythink, usage_listhelp, @@ -1667,16 +1707,20 @@ run `man ponysay`. Ponysay has so much more to offer than described here.''') opts.add_argumentless(['--quoters']) opts.add_argumentless(['--onelist']) +opts.add_argumentless(['++onelist']) 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', '--altlist'], help = 'List pony names with alternatives.') +opts.add_argumentless(['+l', '++list'], help = 'List non-MLP:FiM pony names.') +opts.add_argumentless(['+L', '++altlist'], help = 'List non-MLP:FiM pony names with alternatives.') opts.add_argumentless(['-B', '--balloonlist'], help = 'List balloon styles.') opts.add_argumentless(['-c', '--compact'], help = 'Compress messages.') opts.add_argumented( ['-W', '--wrap'], arg = 'COLUMN', help = 'Specify the column when 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_variadic( ['-q', '--quote'], arg = 'PONY', help = 'Select a ponies which will quote themself.') opts.parse() |