#!/usr/bin/perl -w

# Convert an input file containing a Graph::Easy description to
# ASCII art.

# Example usage:
#  examples/as_ascii t/in/2nodes.txt
#  echo "[ A ] -> [ B ]" | examples/as_ascii

BEGIN { $|++; }

use lib 'lib';
use Graph::Easy::Parser;

my $file = shift;
my $id = shift || '';
my $debug = shift;

my $parser = Graph::Easy::Parser->new( debug => $debug );

$file = \*STDIN unless defined $file;
my $graph = $parser->from_file( $file );

die ($parser->error()) unless defined $graph;

$graph->id($id);
$graph->layout();

warn($graph->error()) if $graph->error();

print $graph->as_ascii();

