1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scripts/help_generator.pl Sun Dec 29 15:28:24 2013 +0100
1.3 @@ -0,0 +1,58 @@
1.4 +#!/usr/bin/perl
1.5 +
1.6 +# SQL-DK
1.7 +# Copyright © 2013 František Kučera (frantovo.cz)
1.8 +#
1.9 +# This program is free software: you can redistribute it and/or modify
1.10 +# it under the terms of the GNU General Public License as published by
1.11 +# the Free Software Foundation, either version 3 of the License, or
1.12 +# (at your option) any later version.
1.13 +#
1.14 +# This program is distributed in the hope that it will be useful,
1.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 +# GNU General Public License for more details.
1.18 +#
1.19 +# You should have received a copy of the GNU General Public License
1.20 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1.21 +
1.22 +
1.23 +# Parses Java source code from STDIN and generates simple help
1.24 +# Input (in this order):
1.25 +# info/globalcode/sql/dk/CLIParser.java
1.26 +# info/globalcode/sql/dk/CLIStarter.java
1.27 +
1.28 +# TODO: localization
1.29 +
1.30 +
1.31 +print 'SQL-DK – and SQL batch client
1.32 +
1.33 +Options:
1.34 +
1.35 +';
1.36 +
1.37 +while (<>) {
1.38 + print " " . sprintf("%-24s", $1) . "$3\n" if (/"(.*?)".*? \/\/\s*bash-completion:option(\s*\/\/\s*help:(.*))?/);
1.39 + last if (/\/\/\s*help:exit-codes/);
1.40 +}
1.41 +
1.42 +print '
1.43 +Examples:
1.44 +
1.45 + sql-dk --db MyDatabase --sql "SELECT * FROM table"
1.46 +
1.47 + sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = ? AND b = ?" --data "abc" "def"
1.48 + sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = :paramA AND b = :paramB" --data-named "paramA" "abc" "paramB" "def"
1.49 +
1.50 + sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = ? AND b = ?" --types "varchar,integer" --data "abc" "123"
1.51 + sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = :paramA AND b = :paramB" --types "paramA:varchar,paramB:integer" --data-named "paramA" "abc" "paramB" "123"
1.52 +
1.53 +Exit codes:
1.54 +
1.55 +';
1.56 +
1.57 +while (<>) {
1.58 + print " $1 = $2\n" if (/EXIT_.*?=\s*(\d+)\s*;\s*\/\/\s*doc:(.*)/);
1.59 +}
1.60 +
1.61 +print "\n";