scripts/help_generator.pl
author František Kučera <franta-hg@frantovo.cz>
Thu, 24 Oct 2019 21:43:08 +0200
branchv_0
changeset 250 aae5009bd0af
parent 200 2e351d7c26c4
permissions -rwxr-xr-x
fix license version: GNU GPLv3
     1 #!/usr/bin/perl
     2 
     3 # SQL-DK
     4 # Copyright © 2013 František Kučera (frantovo.cz)
     5 # 
     6 # This program is free software: you can redistribute it and/or modify
     7 # it under the terms of the GNU General Public License as published by
     8 # the Free Software Foundation, version 3 of the License.
     9 # 
    10 # This program is distributed in the hope that it will be useful,
    11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13 # GNU General Public License for more details.
    14 # 
    15 # You should have received a copy of the GNU General Public License
    16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
    17 
    18 
    19 # Parses Java source code from STDIN and generates simple help
    20 # Input (in this order):
    21 #	info/globalcode/sql/dk/CLIParser.java
    22 #	info/globalcode/sql/dk/CLIStarter.java
    23 
    24 # TODO: localization
    25 
    26 
    27 print 'SQL-DK – an SQL batch client
    28 
    29 Options:
    30 
    31 ';
    32 
    33 while (<>) {
    34 	print "	" . sprintf("%-32s", $1) . "$3\n" if (/"(.*?)".*? \/\/\s*bash-completion:option(\s*\/\/\s*help:(.*))?/);
    35 	last if (/\/\/\s*help:exit-codes/);
    36 }
    37 
    38 print '
    39 Examples:
    40 
    41 	sql-dk --db MyDatabase --sql "SELECT * FROM table"
    42 
    43 	sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = ? AND b = ?" --data "abc" "def"
    44 	sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = :paramA AND b = :paramB" --data-named "paramA" "abc" "paramB" "def"
    45 
    46 	sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = ? AND b = ?" --types "varchar,integer" --data "abc" "123"
    47 	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"
    48 
    49 Exit codes:
    50 
    51 ';
    52 
    53 while (<>) {
    54 	print "	$1 = $2\n" if (/EXIT_.*?=\s*(\d+)\s*;\s*\/\/\s*doc:(.*)/);
    55 }
    56 
    57 print "\n";