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.meviz.encoder.EncodingOptions;
18 public class CommandlineHandler {
20 Parameter galleryNameParameter = new Parameter(false, true, false,
21 new eu.svjatoslav.commons.commandline.parameterparser.arguments.String(), "Gallery title. (default is: "
22 + Constants.DEFAULT_GALLERY_TITLE + ").", "-t", "--gallery-title");
24 Parameter workingDirectoryParameter = new Parameter(false, true, true,
25 new eu.svjatoslav.commons.commandline.parameterparser.arguments.String(), "Working directory.", "-w",
26 "--working-directory");
28 public Parser initParser() {
30 final Parser parser = new Parser();
31 parser.addParameter(galleryNameParameter);
32 parser.addParameter(workingDirectoryParameter);
38 * @return {@link EncodingOptions} if commandline arguments were
39 * successfully parsed, or <code>null</code> if parsing error
42 public IndexingOptions parseCommandlineArguments(final String[] args) {
44 final IndexingOptions options = new IndexingOptions();
46 final Parser parser = initParser();
47 if (!parser.parse(args)) {
51 if (galleryNameParameter.isParameterSpecified()) {
52 options.galleryTitle = galleryNameParameter.getArgumentsAsStrings().get(0);
55 if (workingDirectoryParameter.isParameterSpecified()) {
56 options.workingDirectory = workingDirectoryParameter.getArgumentsAsFiles().get(0);
58 options.workingDirectory = new File(System.getProperty("user.dir"));