Downgrade global version - highest version in 9002 on cpan is 1.58 - thus go with...
[dbsrgits/SQL-Translator.git] / bin / sqlt-graph
index c8f72cf..a5804e9 100755 (executable)
@@ -1,9 +1,7 @@
 #!/usr/bin/perl
 
 # -------------------------------------------------------------------
-# $Id: sqlt-graph,v 1.5 2004-03-15 22:47:23 kycl4rk Exp $
-# -------------------------------------------------------------------
-# Copyright (C) 2002-4 SQLFairy Authors
+# Copyright (C) 2002-2009 SQLFairy Authors
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -47,10 +45,18 @@ sqlt-graph - Automatically create a graph from a database schema
                        set to "0" to undefine)
     --width            Image width (in inches, default "8.5", 
                        set to "0" to undefine)
+    --fontsize         custom font size for node and edge labels
+    --fontname         name of custom font (or full path to font file) for 
+                       node, edge, and graph labels
+    --nodeattr         attribute name and value (in key=val syntax) for
+                       nodes; this option may be repeated to specify 
+                       multiple node attributes
+    --edgeattr         same as --nodeattr, but for edge attributes
+    --graphattr        same as --nodeattr, but for graph attributes
     --natural-join     Perform natural joins
     --natural-join-pk  Perform natural joins from primary keys only
-    --show_datatypes   Show datatype of each field
-    --show_sizes       Show column sizes for VARCHAR and CHAR fields
+    --show-datatypes   Show datatype of each field
+    --show-sizes       Show column sizes for VARCHAR and CHAR fields
     --show-constraints Show list of constraints for each field
     -s|--skip          Fields to skip in natural joins
     --debug            Print debugging information
@@ -91,7 +97,7 @@ use Pod::Usage;
 use SQL::Translator;
 
 use vars '$VERSION';
-$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/;
+$VERSION = '1.59';
 
 #
 # Get arguments.
@@ -100,9 +106,14 @@ my (
     $layout, $node_shape, $out_file, $output_type, $db_driver, $add_color, 
     $natural_join, $join_pk_only, $skip_fields, $show_datatypes,
     $show_sizes, $show_constraints, $debug, $help, $height, $width,
-    $no_fields
+    $no_fields, $fontsize, $fontname
 );
 
+# multi-valued options:
+my %edgeattrs = ();
+my %nodeattrs = ();
+my %graphattrs = ();
+
 GetOptions(
     'd|db|f|from=s'    => \$db_driver,
     'o|output:s'       => \$out_file,
@@ -111,14 +122,19 @@ GetOptions(
     't|output-type:s'  => \$output_type,
     'height:f'         => \$height,
     'width:f'          => \$width,
+    'fontsize=i'       => \$fontsize,
+    'fontname=s'       => \$fontname,
+    'nodeattr=s'       => \%nodeattrs,
+    'edgeattr=s'       => \%edgeattrs,
+    'graphattr=s'      => \%graphattrs,
     'c|color'          => \$add_color,
     'no-fields'        => \$no_fields,
     'natural-join'     => \$natural_join,
     'natural-join-pk'  => \$join_pk_only,
     's|skip:s'         => \$skip_fields,
-    'show-datatypes'   => $show_datatypes,
-    'show-sizes'       => $show_sizes,
-    'show-constraints' => $show_constraints,
+    'show-datatypes'   => \$show_datatypes,
+    'show-sizes'       => \$show_sizes,
+    'show-constraints' => \$show_constraints,
     'debug'            => \$debug,
     'h|help'           => \$help,
 ) or die pod2usage;
@@ -146,6 +162,11 @@ my $translator           =  SQL::Translator->new(
         show_constraints => $show_constraints,
         height           => $height || 0,
         width            => $width  || 0,
+        fontsize         => $fontsize,
+        fontname         => $fontname,
+        nodeattrs        => \%nodeattrs,
+        edgeattrs        => \%edgeattrs,
+        graphattrs       => \%graphattrs,
         show_fields      => $no_fields ? 0 : 1,
     },
 ) or die SQL::Translator->error;