From: Arthur Axel "fREW" Schmidt Date: Sat, 9 Oct 2010 08:26:07 +0000 (+0000) Subject: make format-sql actually useful X-Git-Tag: v1.70~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ffce8d5f88fbf0542c9a2667e1df52ef0408431d;p=dbsrgits%2FSQL-Abstract.git make format-sql actually useful --- diff --git a/Makefile.PL b/Makefile.PL index 3334b43..d13d285 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -13,6 +13,7 @@ all_from 'lib/SQL/Abstract.pm'; requires 'List::Util' => 0; requires 'Scalar::Util' => 0; requires 'Class::Accessor::Grouped' => 0.09005; +requires 'Getopt::Long::Descriptive' => 0.086; requires 'Hash::Merge' => 0.12; test_requires "Test::More" => 0.92; @@ -24,6 +25,8 @@ test_requires "Storable" => 0; # for cloning in tests no_index package => 'DBIx::Class::Storage::Debug::PrettyPrint'; no_index directory => 'examples'; +install_script 'format-sql'; + tests_recursive 't'; WriteAll(); diff --git a/script/format-sql b/script/format-sql index 86d008b..6254e83 100755 --- a/script/format-sql +++ b/script/format-sql @@ -1,7 +1,16 @@ #!/usr/bin/env perl use SQL::Abstract::Tree; +use Getopt::Long::Descriptive; -my $sqlat = SQL::Abstract::Tree->new({ profile => 'console' }); +my ($opt, $usage) = describe_options( + 'format-sql %o', + [ 'profile|p=s', "the profile to use", { default => 'console' } ], + [ 'help', "print usage message and exit" ], +); + + print($usage->text), exit if $opt->help; + +my $sqlat = SQL::Abstract::Tree->new({ profile => $opt->profile }); print $sqlat->format($_) . "\n" while <>;