2 * Meviz - Various tools collection to work with multimedia. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
7 package eu.svjatoslav.meviz.htmlindexer;
9 import eu.svjatoslav.commons.cli_helper.parameter_parser.Parser;
10 import eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.DirectoryParameter;
11 import eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.NullParameter;
12 import eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.StringParameter;
13 import eu.svjatoslav.meviz.encoder.EncodingOptions;
17 public class CommandlineHandler {
19 final Parser parser = new Parser();
20 final NullParameter removeIndex = parser.add(
21 new NullParameter("Remove generated index")).addAliases("-r",
23 private final StringParameter galleryNameParameter = parser.add(
24 new StringParameter("Gallery title. (default is: "
25 + Constants.DEFAULT_GALLERY_TITLE + ").")).addAliases("-t",
27 private final DirectoryParameter workingDirectoryParameter = parser
28 .add(new DirectoryParameter("Working directory."))
29 .addAliases("-w", "--working-directory").mustExist();
31 public String getGalleryTitle() {
32 if (galleryNameParameter.isSpecified())
33 return galleryNameParameter.getValue();
34 return Constants.DEFAULT_GALLERY_TITLE;
37 public File getWorkingDirectory() {
38 if (workingDirectoryParameter.isSpecified())
39 return workingDirectoryParameter.getValue();
41 return new File(System.getProperty("user.dir"));
45 * @return {@link EncodingOptions} if commandline arguments were
46 * successfully parsed, or <code>null</code> if parsing error
49 public boolean parseCommandlineArguments(final String[] args) {
50 final boolean parsingSucceeded = parser.parse(args);
52 if (!parsingSucceeded)
55 return parsingSucceeded;