contrib/dump-asy.pl: add prerequisites check and fix warnings about empty container names

This commit is contained in:
walker0643 2018-02-21 16:55:55 -05:00
parent d2e86da84f
commit 5f453914a0
1 changed files with 7 additions and 1 deletions

View File

@ -15,6 +15,12 @@ use AnyEvent::I3;
use File::Temp; use File::Temp;
use File::Basename; use File::Basename;
use v5.10; use v5.10;
use IPC::Cmd qw[can_run];
# prerequisites check so we can be specific about failures caused
# by not having these tools in the path
can_run('asy') or die 'Please install asymptote';
can_run('gv') or die 'Please install gv';
my $i3 = i3(); my $i3 = i3();
@ -31,7 +37,7 @@ sub dump_node {
my $o = ($n->{orientation} eq 'none' ? "u" : ($n->{orientation} eq 'horizontal' ? "h" : "v")); my $o = ($n->{orientation} eq 'none' ? "u" : ($n->{orientation} eq 'horizontal' ? "h" : "v"));
my $w = (defined($n->{window}) ? $n->{window} : "N"); my $w = (defined($n->{window}) ? $n->{window} : "N");
my $na = $n->{name}; my $na = ($n->{name} or "[Empty]");
$na =~ s/#/\\#/g; $na =~ s/#/\\#/g;
$na =~ s/\$/\\\$/g; $na =~ s/\$/\\\$/g;
$na =~ s/&/\\&/g; $na =~ s/&/\\&/g;