play.pl: change -fmt args separator and fix warnings

This commit is contained in:
wowaname 2016-10-21 20:29:31 +00:00
parent 84d82e0558
commit 9b109be00e

View File

@ -13,11 +13,12 @@ our (%queue, %timer);
if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION, if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
$SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) { $SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
weechat::hook_command('play', 'Play ASCII art', weechat::hook_command('play', 'Play ASCII art',
qq([-delay ms] [-find] [-pipe "command"] [-fmt "text"] filename\n-stop), qq([-delay ms] [-find] [-pipe "command"] [-fmt "list"] filename\n-stop),
"-delay: delay in milliseconds between lines\n". "-delay: delay in milliseconds between lines\n".
"-find: list matching files, don't play\n". "-find: list matching files, don't play\n".
"-pipe: pipe output into command\n". "-pipe: pipe output into command\n".
"-fmt: treat file as a format string and replace with text\n". "-fmt: treat file as a format string and replace with arguments in\n".
" list. Arguments are separated by semicolons (;)\n".
"filename: file to play. Supports wildcards. By default, searches\n". "filename: file to play. Supports wildcards. By default, searches\n".
" subdirectories as well unless '/' is found in the filename\n". " subdirectories as well unless '/' is found in the filename\n".
"-stop: stop currently playing file in buffer", "-stop: stop currently playing file in buffer",
@ -114,7 +115,8 @@ sub cmd_play {
if ($path and open FH, "<", $path) { if ($path and open FH, "<", $path) {
my @lines; my @lines;
while (<FH>) { while (<FH>) {
$_ = sprintf $_, split ' ', $fmt if $fmt; no warnings; # sprintf barks if there's nothing to replace
$_ = sprintf $_, split ';', $fmt if $fmt;
push @lines, s/[\r\n]*$//r push @lines, s/[\r\n]*$//r
} }
close FH; close FH;