Last active
August 29, 2015 14:12
-
-
Save joshmfrankel/babc040cea4eb0164fe2 to your computer and use it in GitHub Desktop.
Perl: ParseDiaSql Output file patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' | |
| if 0; # not running under some shell | |
| # $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 $output = undef; | |
| GetOptions( | |
| "help|?" => \$help, | |
| "file=s" => \$file, | |
| "db=s" => \$db, | |
| "uml" => \$uml, | |
| "loglevel=s" => \$loglevel, | |
| "ignore_type_mismatch" => \$ignore_type_mismatch, | |
| "output=s" => \$output, | |
| ) 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 | |
| ); | |
| if (defined $output) | |
| { | |
| open (MYFILE, ">>$output"); | |
| print MYFILE $dia->get_sql(); | |
| close (MYFILE); | |
| } else { | |
| print $dia->get_sql(); | |
| } | |
| __END__ | |
| =pod | |
| =head1 NAME | |
| parsediasql - Command-line interface to Parse::Dia::SQL | |
| =head1 SYNOPSIS | |
| 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 | |
| DEBUG|INFO|WARN|ERROR|FATAL|TRACE|ALL|OFF. | |
| =head1 DESCRIPTION | |
| 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 | |
| =over | |
| =item * | |
| Add options that correspond to %param in Parse::Dia::SQL::new | |
| =back | |
| =head1 SEE ALSO | |
| Parse::Dia::SQL | |
| =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 | |
| CPAN. | |
| =cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment