diff --git a/src/main/java/net/knarcraft/ffmpegconverter/parser/ConverterArgument.java b/src/main/java/net/knarcraft/ffmpegconverter/parser/ConverterArgument.java index 81d2c70..b1be41d 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/parser/ConverterArgument.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/parser/ConverterArgument.java @@ -1,20 +1,60 @@ package net.knarcraft.ffmpegconverter.parser; /** - * A class representing an argument + * A class representing a command argument */ public class ConverterArgument { + private final String name; + private final char shorthand; private final boolean valueRequired; private final ConverterArgumentValue valueType; - public ConverterArgument(String name, boolean valueRequired, ConverterArgumentValue valueType) { + /** + * Instantiates a converter argument + * @param name

The name of the argument which users has to type.

+ * @param shorthand

A single character value for using the command.

+ * @param valueRequired

Whether the argument must be followed by a valid value.

+ * @param valueType

The type of value the argument requires.

+ */ + public ConverterArgument(String name, char shorthand, boolean valueRequired, ConverterArgumentValue valueType) { this.name = name; + this.shorthand = shorthand; this.valueRequired = valueRequired; this.valueType = valueType; } - private boolean testArgumentValue(String value) { + /** + * Gets the argument name + * @return

The argument name.

+ */ + public String getName() { + return name; + } + + /** + * Gets the argument shorthand + * @return

The argument shorthand

+ */ + public char getShorthand() { + return shorthand; + } + + /** + * Gets whether the argument requires a value + * @return

Whether the argument requires a value.

+ */ + public boolean isValueRequired() { + return valueRequired; + } + + /** + * Tests whether the given value is valid for this converter argument + * + * @param value

The value to test.

+ * @return

True if the argument is valid. False otherwise.

+ */ + public boolean testArgumentValue(String value) { if (value.length() == 0) { return !valueRequired; } @@ -26,9 +66,9 @@ public class ConverterArgument { String lower = value.toLowerCase(); return lower.equals("true") || lower.equals("false"); case COMMA_SEPARATED_LIST: - return !value.contains(" "); - case SINGLE_VALUE: - return !value.contains(" "); + return true; + case STRING: + return true; case INT: int ignored = Integer.parseInt(value); return true;