Created
September 3, 2018 13:34
-
-
Save bduggan/8c5c2dba39cfdb52ff1f1598b28b11b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
sub spinner() { | |
<\ - | - / ->[$++ % 6] | |
} | |
sub MAIN($expr, $filename) { | |
shell "tput 'civis'"; | |
my $proc = Proc::Async.new: | |
<<tail -f $filename>>; | |
my $out = $proc.stdout; | |
start react { | |
whenever $out.lines.grep( / "$expr" / ) { | |
.say | |
} | |
whenever $out.lines { | |
print spinner() ~ "\r"; | |
} | |
whenever signal(SIGINT) { | |
shell 'tput cnorm'; | |
exit; | |
} | |
} | |
await $proc.start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment