From df245bb48f6facee3e19389633556eb2f5d8315e Mon Sep 17 00:00:00 2001 From: Ildar Shaimordanov Date: Sun, 28 Dec 2014 22:57:31 +0400 Subject: [PATCH 1/5] SQL::Beautify::VERSION within BEGIN block --- lib/SQL/Beautify.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/SQL/Beautify.pm b/lib/SQL/Beautify.pm index 7687efc..1740eee 100644 --- a/lib/SQL/Beautify.pm +++ b/lib/SQL/Beautify.pm @@ -4,7 +4,9 @@ package SQL::Beautify; use strict; use warnings; -our $VERSION = 0.04; +BEGIN { + our $VERSION = 0.04; +} use SQL::Tokenizer; use Carp; From 5d9b2c9778f6c1e32891ba555a7b4fc4c1900286 Mon Sep 17 00:00:00 2001 From: Ildar Shaimordanov Date: Sun, 8 Mar 2015 21:43:17 +0400 Subject: [PATCH 2/5] beautify help to be used with Pod::Usage --- script/sqlbeautify | 53 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/script/sqlbeautify b/script/sqlbeautify index 5db0c87..280c715 100755 --- a/script/sqlbeautify +++ b/script/sqlbeautify @@ -3,6 +3,7 @@ use strict; use warnings; use Getopt::Long qw(GetOptions); +use Pod::Usage; use SQL::Beautify; @@ -10,9 +11,10 @@ my %opt; GetOptions(\%opt, 'spaces=i', - 'help' => sub { usage(); }, + 'h|help' => sub { pod2usage({ -verbose => 2}); }, ); -usage() unless @ARGV || ! -t 0; + +pod2usage unless @ARGV || ! -t 0; my $orig_sql = eval { local $/ = undef; @@ -24,15 +26,42 @@ $sql->query($orig_sql); my $nice_sql = $sql->beautify; print $nice_sql; -sub usage { - print <<"END_USAGE"; -v$SQL::Beautify::VERSION -Usage: $0 [options] FILEs - --spaces 4 - number of indentation spaces (defaults to 4) - - --help - this help -END_USAGE - exit; -} +=head1 NAME + +Beautifier of SQL statements by adding line breaks indentation. + +=head1 SYNOPSIS + + sqlbeautify --help + sqlbeautify [options] FILEs + +=head1 DESCRIPTION + +The application to beautify SQL statements by adding line breaks +indentation. It is based on the SQL::Beautify package. + +=head1 OPTIONS + +=over + +=item B + + --help + +This help. + +=item B + + --spaces 4 + +Number of indentation spaces (defaults to 4). + +=back + +=head1 COPYRIGHT + +Copyright (C) 2009 by Jonas Kramer. Published under the terms of the +Artistic License 2.0. +=cut From 514ca6b090d98116ff4833ffe6b0e2fae5cc02a6 Mon Sep 17 00:00:00 2001 From: Ildar Shaimordanov Date: Sun, 8 Mar 2015 22:01:19 +0400 Subject: [PATCH 3/5] more beautified actions: - --uc_keywords option added - -h, -s, -u short options added - POD updated to reflect the changes --- script/sqlbeautify | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/script/sqlbeautify b/script/sqlbeautify index 280c715..bbbed8e 100755 --- a/script/sqlbeautify +++ b/script/sqlbeautify @@ -10,7 +10,8 @@ use SQL::Beautify; my %opt; GetOptions(\%opt, - 'spaces=i', + 's|spaces=i', + 'u|uc_keywords' => sub { $opt{uc_keywords} = 1; }, 'h|help' => sub { pod2usage({ -verbose => 2}); }, ); @@ -47,16 +48,26 @@ indentation. It is based on the SQL::Beautify package. =item B + -h --help -This help. +Prints this help. =item B + -s 4 --spaces 4 Number of indentation spaces (defaults to 4). +=item B + + -u + --uc_keywords + +When specified all SQL keywords will be uppercased in output. Default is +lowercase. + =back =head1 COPYRIGHT From 15b11853092c88b2db6d8332d20b575afc904ab8 Mon Sep 17 00:00:00 2001 From: Ildar Shaimordanov Date: Sat, 30 May 2015 08:46:21 +0400 Subject: [PATCH 4/5] ending semicolon added at the end of code in SQL::Beautify --- lib/SQL/Beautify.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SQL/Beautify.pm b/lib/SQL/Beautify.pm index 1740eee..9fc18c0 100644 --- a/lib/SQL/Beautify.pm +++ b/lib/SQL/Beautify.pm @@ -379,7 +379,7 @@ sub _is_punctuation { } -1 +1; __END__ From a08924b7697a3a0356b8364d16689f568f881546 Mon Sep 17 00:00:00 2001 From: ildar-shaimordanov Date: Thu, 17 Dec 2020 16:02:26 +0300 Subject: [PATCH 5/5] internal change to cli options; --- script/sqlbeautify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/sqlbeautify b/script/sqlbeautify index bbbed8e..9c7ab28 100755 --- a/script/sqlbeautify +++ b/script/sqlbeautify @@ -10,7 +10,7 @@ use SQL::Beautify; my %opt; GetOptions(\%opt, - 's|spaces=i', + 's|spaces=i' => sub { $opt{spaces} = $_[1]; }, 'u|uc_keywords' => sub { $opt{uc_keywords} = 1; }, 'h|help' => sub { pod2usage({ -verbose => 2}); }, );