2 * Meviz - Various tools collection to work with multimedia.
3 * Copyright (C) 2012 -- 2018, 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.bomremove;
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.StringParameters;
19 class CommandlineHandler {
21 final Parser parser = new Parser();
23 private final NullParameter recursiveParameter = parser.add(
24 new NullParameter("Enable recursive mode.")).addAliases("-r",
27 private final StringParameters inputPatternParameter = parser.add(
28 new StringParameters("File input pattern.")).addAliases("-i",
31 private final DirectoryParameter workingDirectoryParameter = parser
32 .add(new DirectoryParameter("Working directory."))
33 .addAliases("-w", "--working-directory").mustExist();
35 public BomStrippingOptions parseCommandlineArguments(final String[] args) {
37 final BomStrippingOptions options = new BomStrippingOptions();
39 if (!parser.parse(args))
42 if (recursiveParameter.isSpecified())
43 options.recursive = true;
45 if (workingDirectoryParameter.isSpecified())
46 options.targetDirectory = workingDirectoryParameter.getValue();
48 options.targetDirectory = new File(System.getProperty("user.dir"));
50 // TODO: add support for multiple input patterns
51 if (inputPatternParameter.isSpecified())
52 options.inputPatterns.addAll(inputPatternParameter.getValue());