package jalview.bin.argparser;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
return description;
}
+ public static String booleanArgString(Arg a)
+ {
+ StringBuilder sb = new StringBuilder(a.argString());
+ if (a.hasOption(Opt.BOOLEAN))
+ {
+ sb.append('/');
+ sb.append(a.negateArgString());
+ }
+ return sb.toString();
+ }
+
public static final String usage()
{
StringBuilder sb = new StringBuilder();
int maxArgLength = 0;
for (Arg a : EnumSet.allOf(Arg.class))
{
+ if (a.hasOption(Opt.PRIVATE))
+ continue;
StringBuilder argSb = new StringBuilder();
argSb.append(a.hasOption(Opt.BOOLEAN) ? booleanArgString(a)
: a.argString());
maxArgLength = argSb.length();
}
- // might want to order these
+ // might want to sort these
for (Arg a : EnumSet.allOf(Arg.class))
{
+ if (a.hasOption(Opt.PRIVATE))
+ continue;
StringBuilder argSb = new StringBuilder();
argSb.append(a.hasOption(Opt.BOOLEAN) ? booleanArgString(a)
: a.argString());
argSb.append("=value");
sb.append(String.format("%-" + maxArgLength + "s - %s",
argSb.toString(), a.getDescription()));
+
+ List<String> options = new ArrayList<>();
+
if (a.hasOption(Opt.BOOLEAN))
{
- sb.append(" (default ");
- sb.append(a.getDefaultBoolValue() ? a.argString()
- : a.negateArgString());
+ options.add("default " + (a.getDefaultBoolValue() ? a.argString()
+ : a.negateArgString()));
+ }
+
+ if (a.hasOption(Opt.MULTI))
+ {
+ options.add("multiple");
+ }
+
+ if (a.hasOption(Opt.LINKED))
+ {
+ options.add("can be linked");
+ }
+
+ if (a.hasOption(Opt.GLOB))
+ {
+ options.add("allows file globs");
+ }
+
+ if (a.hasOption(Opt.ALLOWSUBSTITUTIONS))
+ {
+ options.add("allows substitutions");
+ }
+
+ if (options.size() > 0)
+ {
+ sb.append(" (");
+ sb.append(String.join("; ", options));
sb.append(')');
}
sb.append(System.lineSeparator());
}
return sb.toString();
}
-
- public static String booleanArgString(Arg a)
- {
- StringBuilder sb = new StringBuilder(a.argString());
- if (a.hasOption(Opt.BOOLEAN))
- {
- sb.append('/');
- sb.append(a.negateArgString());
- }
- return sb.toString();
- }
}
\ No newline at end of file