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.bomremove;
14 import eu.svjatoslav.commons.commandline.parameterparser.Parser;
15 import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter;
16 import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter;
17 import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters;
19 public class CommandlineHandler {
21 Parser parser = new Parser();
23 NullParameter recursiveParameter = parser.add(
24 new NullParameter("Enable recursive mode.")).addAliases("-r",
27 StringParameters inputPatternParameter = parser.add(
28 new StringParameters("File input pattern.")).addAliases("-i",
31 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.isParameterSpecified())
43 options.recursive = true;
45 if (workingDirectoryParameter.isParameterSpecified())
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.isParameterSpecified())
52 options.inputPatterns.addAll(inputPatternParameter.getValue());