2 * Meviz - Various tools collection to work with multimedia.
3 * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
10 package eu.svjatoslav.meviz.htmlindexer;
12 import eu.svjatoslav.commons.commandline.parameterparser.Parser;
13 import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter;
14 import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter;
15 import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter;
16 import eu.svjatoslav.meviz.encoder.EncodingOptions;
20 class CommandlineHandler {
22 final Parser parser = new Parser();
23 final NullParameter removeIndex = parser.add(
24 new NullParameter("Remove generated index")).addAliases("-r",
26 private final StringParameter galleryNameParameter = parser.add(
27 new StringParameter("Gallery title. (default is: "
28 + Constants.DEFAULT_GALLERY_TITLE + ").")).addAliases("-t",
30 private final DirectoryParameter workingDirectoryParameter = parser
31 .add(new DirectoryParameter("Working directory."))
32 .addAliases("-w", "--working-directory").mustExist();
34 public String getGalleryTitle() {
35 if (galleryNameParameter.isParameterSpecified())
36 return galleryNameParameter.getValue();
37 return Constants.DEFAULT_GALLERY_TITLE;
40 public File getWorkingDirectory() {
41 if (workingDirectoryParameter.isParameterSpecified())
42 return workingDirectoryParameter.getValue();
44 return new File(System.getProperty("user.dir"));
48 * @return {@link EncodingOptions} if commandline arguments were
49 * successfully parsed, or <code>null</code> if parsing error
52 public boolean parseCommandlineArguments(final String[] args) {
53 final boolean parsingSucceeded = parser.parse(args);
55 if (!parsingSucceeded)
58 return parsingSucceeded;