aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorOrestis Floros <orestisf1993@gmail.com>2018-03-14 12:18:58 +0200
committerOrestis Floros <orestisf1993@gmail.com>2018-03-14 14:32:16 +0200
commit883cf4041d6fcccf8d3003ed279d7fc0fa984bce (patch)
treec129b65683257f5e5120ee5ed3e69fa354c9885a /contrib
parent9521f69e11e68a5fdc855c738f4cf500f5ccad7a (diff)
downloadi3-883cf4041d6fcccf8d3003ed279d7fc0fa984bce.tar.gz
i3-883cf4041d6fcccf8d3003ed279d7fc0fa984bce.zip
dump-asy.pl: Add --gv option
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/dump-asy.pl27
1 files changed, 24 insertions, 3 deletions
diff --git a/contrib/dump-asy.pl b/contrib/dump-asy.pl
index 54a1e490..866cf8e0 100755
--- a/contrib/dump-asy.pl
+++ b/contrib/dump-asy.pl
@@ -8,14 +8,17 @@ use Getopt::Long;
use Pod::Usage;
use AnyEvent::I3;
use File::Temp;
+use File::Spec;
use File::Basename;
use v5.10;
use IPC::Cmd qw[can_run];
my %options = (
+ gv => 1,
help => 0,
);
my $result = GetOptions(
+ "gv!" => \$options{gv},
"help|?" => \$options{help},
);
@@ -24,7 +27,7 @@ pod2usage(-verbose => 2, -exitcode => 0) if $options{help};
# 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';
+can_run('gv') or die 'Please install gv' unless !$options{gv};
my $i3 = i3();
@@ -86,8 +89,13 @@ say $tmp "draw(n" . $root->{id} . ", (0, 0));";
close($tmp);
my $rep = "$tmp";
$rep =~ s/asy$/eps/;
-my $tmp_dir = dirname($rep);
-system("cd $tmp_dir && asy $tmp && gv --scale=-1000 --noresize --widgetless $rep && rm $rep");
+if ($options{gv}) {
+ my $tmp_dir = dirname($rep);
+ chdir($tmp_dir);
+}
+system("asy $tmp"); # Create the .eps file.
+system("gv --scale=-1000 --noresize --widgetless $rep && rm $rep") if $options{gv};
+system("rm $tmp");
__END__
@@ -108,3 +116,16 @@ Render the entire tree, run:
Render the tree starting from the node with the specified name, run:
./dump-asy.pl 'name'
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--gv>
+
+=item B<--no-gv>
+
+Enable or disable showing the result through gv. If disabled, an .eps file will
+be saved in the current working directory. Enabled by default.
+
+=back