X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fcommons%2Fcommandline%2Fparameterparser%2FParameter.java;h=461f13aad5e50d0cabbf19146a8a7305bd0a3b68;hb=443c6a564efa9f5868fd81c0db23a480cbe3cab4;hp=32e9594d777c2ce029bbe2bd6fbf40c43568e826;hpb=c378ab1acf1d7299a572e4a5fc38996ee0408602;p=svjatoslav_commons.git diff --git a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java index 32e9594..461f13a 100755 --- a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java +++ b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java @@ -1,6 +1,6 @@ /* * Svjatoslav Commons - shared library of common functionality. - * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License @@ -11,13 +11,20 @@ package eu.svjatoslav.commons.commandline.parameterparser; import java.util.ArrayList; import java.util.Collections; +import java.util.List; public abstract class Parameter { + /** + * Purpose of this argument, like: input image path, compression level, etc... + * + * Note: for describing argument type (file, integer, ...) there is {@link #describeFormat()}. + */ public final String description; - public final ArrayList arguments = new ArrayList<>(); + + public final List arguments = new ArrayList<>(); final ArgumentCount argumentCount; - private final ArrayList aliases = new ArrayList<>(); + private final List aliases = new ArrayList<>(); /** * Indicates that at least one argument is mandatory for this parameter. */ @@ -92,7 +99,10 @@ public abstract class Parameter { } /** - * @return Single line argument type description. + * @return Single line argument type description. If argument type should be file, + * date, integer, regular expression, etc.. + * + * Note: for argument purpose description there is {@link #description} */ public abstract String describeFormat(); @@ -116,7 +126,11 @@ public abstract class Parameter { // first line buffer.append(getAliases()); if (!argumentCount.equals(ArgumentCount.NONE)) { - buffer.append(" (" + describeFormat() + ")"); + buffer + .append(" (") + .append(isMandatory() ? "mandatory, " : "") + .append(describeFormat()) + .append(")"); if (argumentCount.equals(ArgumentCount.MULTI)) buffer.append("...");