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;
14 import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
15 import eu.svjatoslav.commons.commandline.parameterparser.Parser;
16 import eu.svjatoslav.commons.commandline.parameterparser.arguments.StringArgument;
17 import eu.svjatoslav.meviz.encoder.EncodingOptions;
19 public class CommandlineHandler {
21 Parameter galleryNameParameter = new Parameter(false, true, false,
22 new StringArgument(), "Gallery title. (default is: "
23 + Constants.DEFAULT_GALLERY_TITLE + ").", "-t",
26 Parameter workingDirectoryParameter = new Parameter(false, true, true,
27 new StringArgument(), "Working directory.", "-w",
28 "--working-directory");
30 public Parser initParser() {
32 final Parser parser = new Parser();
33 parser.addParameter(galleryNameParameter);
34 parser.addParameter(workingDirectoryParameter);
40 * @return {@link EncodingOptions} if commandline arguments were
41 * successfully parsed, or <code>null</code> if parsing error
44 public IndexingOptions parseCommandlineArguments(final String[] args) {
46 final IndexingOptions options = new IndexingOptions();
48 final Parser parser = initParser();
49 if (!parser.parse(args))
52 if (galleryNameParameter.isParameterSpecified())
53 options.galleryTitle = galleryNameParameter.getArgumentsAsStrings()
56 if (workingDirectoryParameter.isParameterSpecified())
57 options.workingDirectory = workingDirectoryParameter
58 .getArgumentsAsFiles().get(0);
60 options.workingDirectory = new File(System.getProperty("user.dir"));