# $Id: parsediasql,v 1.10 2011/02/16 10:23:11 aff Exp $

use strict;
use warnings;

use Getopt::Long;
use Pod::Usage;

use lib q{lib};
use Parse::Dia::SQL;

my $help                 = undef;
my $file                 = undef;
my $ignore_type_mismatch = undef;
my $db                   = undef;
my $uml                  = undef;
my $loglevel             = undef;
my $backticks            = undef;
my $htmlformat           = undef;

  "help|?"               => \$help,
  "file=s"               => \$file,
  "db=s"                 => \$db,
  "uml"                  => \$uml,
  "loglevel=s"           => \$loglevel,
  "backticks=i"          => \$backticks,
  "ignore_type_mismatch" => \$ignore_type_mismatch,
  "htmlformat=s"         => \$htmlformat,
) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(qq{Missing argument 'file'}) if !$file;
pod2usage(qq{Missing argument 'db'}) if !$db;

my $dia = Parse::Dia::SQL->new(
  file                 => $file,
  db                   => $db,
  ignore_type_mismatch => $ignore_type_mismatch,
  uml                  => $uml,
  loglevel             => $loglevel,
  backticks            => $backticks,
  htmlformat           => $htmlformat,
print $dia->get_sql();



=head1 NAME

  parsediasql - Command-line interface to Parse::Dia::SQL


  parsediasql [OPTIONS] --file FILE --db DB

=head1 OPTIONS

  file                   - Filename of Dia file
  db                     - Database type (e.g. 'db2')
  ignore_type_mismatch   - Allows foreign keys to have a different
                           type than the primary key it references, 
                           if true. Default false.
  uml                    - Use UML interpretation of the diagram, 
                           default is ERD interpretation.
  loglevel               - Log verbosity, valid values are
  backticks              - Use `backtick` notation (mysql-innodb only).
  htmlformat             - Optional custom format file (html only).


Dia is a diagram creation program for Linux, Unix and Windows released
under the GPL license.

parsediasql is a Command-line interface to Parse::Dia::SQL

Parse::Dia::SQL converts Dia class diagrams into SQL. 

=head1 TODO


=item *

Add options that correspond to %param in Parse::Dia::SQL::new


=head1 SEE ALSO


=head1 AUTHOR

Parse::Dia::SQL is based on I<tedia2sql> by Tim Ellis and others.  See the
I<AUTHORS> file for details.

Modified by Andreas Faafeng, C<< <aff at cpan.org> >> for release on