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 public class CommandlineHandler {
22 Parser parser = new Parser();
24 StringParameter galleryNameParameter = parser.add(
25 new StringParameter("Gallery title. (default is: "
26 + Constants.DEFAULT_GALLERY_TITLE + ").")).addAliases("-t",
29 DirectoryParameter workingDirectoryParameter = parser
30 .add(new DirectoryParameter("Working directory."))
31 .addAliases("-w", "--working-directory").mustExist();
33 NullParameter removeIndex = parser.add(
34 new NullParameter("Remove generated index")).addAliases("-r",
37 public String getGalleryTitle() {
38 if (galleryNameParameter.isParameterSpecified())
39 return galleryNameParameter.getValue();
40 return Constants.DEFAULT_GALLERY_TITLE;
43 public File getWorkingDirectory() {
44 if (workingDirectoryParameter.isParameterSpecified())
45 return workingDirectoryParameter.getValue();
47 return new File(System.getProperty("user.dir"));
51 * @return {@link EncodingOptions} if commandline arguments were
52 * successfully parsed, or <code>null</code> if parsing error
55 public boolean parseCommandlineArguments(final String[] args) {
56 final boolean parsingSucceeded = parser.parse(args);
58 if (!parsingSucceeded)
61 return parsingSucceeded;