java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java
author František Kučera <franta-hg@frantovo.cz>
Mon, 16 Dec 2013 20:20:54 +0100
branchv_0
changeset 17 d8ab8aece6f2
parent 16 5b8fcd35d4d6
child 20 e225bdcd260e
permissions -rw-r--r--
license option: --license
     1 /**
     2  * SQL-DK
     3  * Copyright © 2013 František Kučera (frantovo.cz)
     4  *
     5  * This program is free software: you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation, either version 3 of the License, or
     8  * (at your option) any later version.
     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 package info.globalcode.sql.dk;
    19 
    20 import java.util.logging.Level;
    21 import java.util.logging.Logger;
    22 
    23 /**
    24  *
    25  * @author Ing. František Kučera (frantovo.cz)
    26  */
    27 public class CLIStarter {
    28 
    29 	private static final Logger log = Logger.getLogger(CLIStarter.class.getName());
    30 
    31 	public static void main(String[] args) {
    32 		try {
    33 			/** Parse options */
    34 			CLIParser parser = new CLIParser();
    35 			CLIOptions options = parser.parseOptions(args);
    36 
    37 			options.validate();
    38 
    39 			/** Show info */
    40 			if (!options.getShowInfo().isEmpty()) {
    41 				InfoLister infoLister = new InfoLister(System.err);
    42 				infoLister.showInfo(options);
    43 			}
    44 
    45 		} catch (CLIParserException e) {
    46 			log.log(Level.SEVERE, "Unable to parse CLI options", e);
    47 		} catch (InvalidOptionsException e) {
    48 			log.log(Level.SEVERE, "Invalid CLI options", e);
    49 		}
    50 	}
    51 }