-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsqlbeautify
More file actions
executable file
·78 lines (49 loc) · 1.17 KB
/
sqlbeautify
File metadata and controls
executable file
·78 lines (49 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long qw(GetOptions);
use Pod::Usage;
use SQL::Beautify;
my %opt;
GetOptions(\%opt,
's|spaces=i' => sub { $opt{spaces} = $_[1]; },
'u|uc_keywords' => sub { $opt{uc_keywords} = 1; },
'h|help' => sub { pod2usage({ -verbose => 2}); },
);
pod2usage unless @ARGV || ! -t 0;
my $orig_sql = eval {
local $/ = undef;
<>;
};
my $sql = SQL::Beautify->new(%opt);
$sql->query($orig_sql);
my $nice_sql = $sql->beautify;
print $nice_sql;
=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>
-h
--help
Prints this help.
=item B<spaces>
-s 4
--spaces 4
Number of indentation spaces (defaults to 4).
=item B<uc_keywords>
-u
--uc_keywords
When specified all SQL keywords will be uppercased in output. Default is
lowercase.
=back
=head1 COPYRIGHT
Copyright (C) 2009 by Jonas Kramer. Published under the terms of the
Artistic License 2.0.
=cut