scripts/help_generator.pl
branchv_0
changeset 96 7ae30649b30b
child 100 de65409a9f26
equal deleted inserted replaced
95:714e4fac9cd0 96:7ae30649b30b
       
     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, either version 3 of the License, or
       
     9 # (at your option) any later version.
       
    10 # 
       
    11 # This program is distributed in the hope that it will be useful,
       
    12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       
    14 # GNU General Public License for more details.
       
    15 # 
       
    16 # You should have received a copy of the GNU General Public License
       
    17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
       
    18 
       
    19 
       
    20 # Parses Java source code from STDIN and generates simple help
       
    21 # Input (in this order):
       
    22 #	info/globalcode/sql/dk/CLIParser.java
       
    23 #	info/globalcode/sql/dk/CLIStarter.java
       
    24 
       
    25 # TODO: localization
       
    26 
       
    27 
       
    28 print 'SQL-DK – and SQL batch client
       
    29 
       
    30 Options:
       
    31 
       
    32 ';
       
    33 
       
    34 while (<>) {
       
    35 	print "	" . sprintf("%-24s", $1) . "$3\n" if (/"(.*?)".*? \/\/\s*bash-completion:option(\s*\/\/\s*help:(.*))?/);
       
    36 	last if (/\/\/\s*help:exit-codes/);
       
    37 }
       
    38 
       
    39 print '
       
    40 Examples:
       
    41 
       
    42 	sql-dk --db MyDatabase --sql "SELECT * FROM table"
       
    43 
       
    44 	sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = ? AND b = ?" --data "abc" "def"
       
    45 	sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = :paramA AND b = :paramB" --data-named "paramA" "abc" "paramB" "def"
       
    46 
       
    47 	sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = ? AND b = ?" --types "varchar,integer" --data "abc" "123"
       
    48 	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"
       
    49 
       
    50 Exit codes:
       
    51 
       
    52 ';
       
    53 
       
    54 while (<>) {
       
    55 	print "	$1 = $2\n" if (/EXIT_.*?=\s*(\d+)\s*;\s*\/\/\s*doc:(.*)/);
       
    56 }
       
    57 
       
    58 print "\n";