return buffer.toString();
}
- public File getArgumentAsFile() {
- if (arguments.size() != 1)
- throw new RuntimeException("Parameter " + description
- + " shall have exactly 1 argument.");
- return new File(arguments.get(0));
- }
-
public List<File> getArgumentsAsFiles() {
final ArrayList<File> result = new ArrayList<File>();
import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.FileParameter;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.IntegerParameter;
+import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter;
/**
parameters.add(parameter);
}
+ public Parameter createCustomParameter(final Argument paramaterType,
+ final String description) {
+ final Parameter parameter = new Parameter(paramaterType, description,
+ ArgumentCount.SINGLE);
+ parameters.add(parameter);
+ return parameter;
+ }
+
public DirectoryParameter createDirectoryParameter(final String description) {
final DirectoryParameter parameter = new DirectoryParameter(description);
parameters.add(parameter);
return parameter;
}
+ public NullParameter createNullParameter(final String description) {
+ final NullParameter parameter = new NullParameter(description);
+ parameters.add(parameter);
+ return parameter;
+ }
+
public StringParameter createStringParameter(final String description) {
final StringParameter parameter = new StringParameter(description);
parameters.add(parameter);
--- /dev/null
+package eu.svjatoslav.commons.commandline.parameterparser.parameter;
+
+import eu.svjatoslav.commons.commandline.parameterparser.ArgumentCount;
+import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
+
+public class NullParameter extends Parameter {
+
+ public NullParameter(final String description) {
+ super(null, description, ArgumentCount.SINGLE);
+ }
+
+ @Override
+ public NullParameter addAliases(final String... aliasArray) {
+ super.addAliases(aliasArray);
+ return this;
+ }
+
+ public boolean getValue() {
+ return isParameterSpecified();
+ }
+
+ @Override
+ public NullParameter setMandatory() {
+ mandatory = true;
+ return this;
+ }
+}