/*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
+ * Meviz - Various tools collection to work with multimedia. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
*/
+
package eu.svjatoslav.meviz.replace;
import eu.svjatoslav.commons.commandline.parameterparser.Parser;
import java.io.File;
-public class CommandlineHandler {
+class CommandlineHandler {
- Parser parser = new Parser();
+ final Parser parser = new Parser();
- NullParameter recursiveParameter = parser.add(
+ private final NullParameter recursiveParameter = parser.add(
new NullParameter("Enable recursive mode.")).addAliases("-r",
"--recursive");
- StringParameter searchForPattern = parser
+ private final StringParameter searchForPattern = parser
.add(new StringParameter("String to search for"))
.addAliases("-s", "--search-pattern").setMandatory();
- StringParameter replaceWithPattern = parser.add(
+ private final StringParameter replaceWithPattern = parser.add(
new StringParameter("String to place instead")).addAliases("-p",
"--replace-pattern");
- DirectoryParameter directoryParameter = parser
+ private final DirectoryParameter directoryParameter = parser
.add(new DirectoryParameter("Working directory."))
.addAliases("-w", "--working-directory").mustExist();
if (!parser.parse(args))
return null;
- if (recursiveParameter.isParameterSpecified())
+ if (recursiveParameter.isSpecified())
options.recursive = true;
- if (directoryParameter.isParameterSpecified())
+ if (directoryParameter.isSpecified())
options.targetDirectory = directoryParameter.getValue();
else
options.targetDirectory = new File(System.getProperty("user.dir"));
- if (searchForPattern.isParameterSpecified())
+ if (searchForPattern.isSpecified())
options.searchForPattern = searchForPattern.getValue();
- if (replaceWithPattern.isParameterSpecified())
+ if (replaceWithPattern.isSpecified())
options.replaceWithPattern = replaceWithPattern.getValue();
return options;