3 * Copyright © 2014 František Kučera (frantovo.cz)
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.
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.
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/>.
18 package cz.frantovo.copyImageResizer.cli;
20 import cz.frantovo.copyImageResizer.Counters;
21 import cz.frantovo.copyImageResizer.InvalidOptionsException;
22 import cz.frantovo.copyImageResizer.RecursiveException;
23 import cz.frantovo.copyImageResizer.RecursiveImageResizer;
24 import cz.frantovo.copyImageResizer.RecursiveOptions;
25 import cz.frantovo.copyImageResizer.ResizeException;
26 import java.util.logging.Level;
27 import java.util.logging.LogRecord;
28 import java.util.logging.Logger;
32 * @author Ing. František Kučera (frantovo.cz)
34 public class CLIStarter {
36 private static final Logger log = Logger.getLogger(CLIStarter.class.getName());
38 public static void main(String[] args) {
41 CLIParser parser = new CLIParser();
42 RecursiveOptions options = parser.parseOptions(args);
44 RecursiveImageResizer resizer = new RecursiveImageResizer(options);
45 Counters counters = resizer.resize();
46 log.log(Level.INFO, "Recursive copy/resize finished. {0}", counters);
47 } catch (CLIParserException e) {
48 log.log(Level.SEVERE, "Unable to parse CLI options", e);
49 } catch (InvalidOptionsException e) {
50 log.log(Level.SEVERE, "Invalid CLI options", e);
51 for (InvalidOptionsException.OptionProblem p : e.getProblems()) {
52 LogRecord r = new LogRecord(Level.SEVERE, "Option problem: {0}");
53 r.setThrown(p.getException());
54 r.setParameters(new Object[]{p.getDescription()});
57 } catch (RecursiveException e) {
58 log.log(Level.SEVERE, "Error while processing filesystem hierarchy", e);
59 } catch (ResizeException e) {
60 log.log(Level.SEVERE, "Error while resizing image", e);