franta-hg@96: #!/usr/bin/perl franta-hg@96: franta-hg@96: # SQL-DK franta-hg@96: # Copyright © 2013 František Kučera (frantovo.cz) franta-hg@96: # franta-hg@96: # This program is free software: you can redistribute it and/or modify franta-hg@96: # it under the terms of the GNU General Public License as published by franta-hg@96: # the Free Software Foundation, either version 3 of the License, or franta-hg@96: # (at your option) any later version. franta-hg@96: # franta-hg@96: # This program is distributed in the hope that it will be useful, franta-hg@96: # but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@96: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@96: # GNU General Public License for more details. franta-hg@96: # franta-hg@96: # You should have received a copy of the GNU General Public License franta-hg@96: # along with this program. If not, see . franta-hg@96: franta-hg@96: franta-hg@96: # Parses Java source code from STDIN and generates simple help franta-hg@96: # Input (in this order): franta-hg@96: # info/globalcode/sql/dk/CLIParser.java franta-hg@96: # info/globalcode/sql/dk/CLIStarter.java franta-hg@96: franta-hg@96: # TODO: localization franta-hg@96: franta-hg@96: franta-hg@100: print 'SQL-DK – an SQL batch client franta-hg@96: franta-hg@96: Options: franta-hg@96: franta-hg@96: '; franta-hg@96: franta-hg@96: while (<>) { franta-hg@200: print " " . sprintf("%-32s", $1) . "$3\n" if (/"(.*?)".*? \/\/\s*bash-completion:option(\s*\/\/\s*help:(.*))?/); franta-hg@96: last if (/\/\/\s*help:exit-codes/); franta-hg@96: } franta-hg@96: franta-hg@96: print ' franta-hg@96: Examples: franta-hg@96: franta-hg@96: sql-dk --db MyDatabase --sql "SELECT * FROM table" franta-hg@96: franta-hg@96: sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = ? AND b = ?" --data "abc" "def" franta-hg@96: sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = :paramA AND b = :paramB" --data-named "paramA" "abc" "paramB" "def" franta-hg@96: franta-hg@96: sql-dk --db MyDatabase --sql "SELECT * FROM table WHERE a = ? AND b = ?" --types "varchar,integer" --data "abc" "123" franta-hg@96: 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" franta-hg@96: franta-hg@96: Exit codes: franta-hg@96: franta-hg@96: '; franta-hg@96: franta-hg@96: while (<>) { franta-hg@96: print " $1 = $2\n" if (/EXIT_.*?=\s*(\d+)\s*;\s*\/\/\s*doc:(.*)/); franta-hg@96: } franta-hg@96: franta-hg@96: print "\n";