Skip to content

Instantly share code, notes, and snippets.

@bduggan
Created September 3, 2018 13:34
Show Gist options
  • Save bduggan/8c5c2dba39cfdb52ff1f1598b28b11b5 to your computer and use it in GitHub Desktop.
Save bduggan/8c5c2dba39cfdb52ff1f1598b28b11b5 to your computer and use it in GitHub Desktop.
#!/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