Skip to content

Commit 25a2779

Browse files
committed
Future-proof additional command info; print warning instead of throwing an exception for invalid/incomplete entries. (#509)
1 parent b68b58e commit 25a2779

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

metafacture-flux/src/main/java/org/metafacture/flux/HelpPrinter.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@
4949
* @author Markus Michael Geipel
5050
*/
5151
public final class HelpPrinter {
52+
5253
private static final String PATH_TO_EXAMPLES = "../metafacture-documentation/linksAndExamples.tsv";
5354
private static final Map<String, String[]> EXAMPLES_MAP = new HashMap<>();
54-
private static final int COLUMN_TO_PG_EXAMPLE = 3;
55-
private static final int MAX_COLUMNS_OF_EXAMPLE = COLUMN_TO_PG_EXAMPLE;
56-
private static final int MIN_COLUMNS_OF_EXAMPLE = 2;
5755

5856
private HelpPrinter() {
5957
// no instances
@@ -127,17 +125,10 @@ private static <T> void describe(final String name, final ObjectFactory<T> facto
127125
printSignature(out, moduleClass);
128126

129127
final String[] examplesEntry = EXAMPLES_MAP.get(name);
130-
if (!EXAMPLES_MAP.isEmpty() && (examplesEntry == null || examplesEntry.length < MIN_COLUMNS_OF_EXAMPLE ||
131-
examplesEntry.length > MAX_COLUMNS_OF_EXAMPLE)) {
132-
throw new MetafactureException(
133-
"Failed to load build infos: tsv with links hasn't at least " + MIN_COLUMNS_OF_EXAMPLE + " " +
134-
"or exceeds the number of allowed columns (i.e. " + MAX_COLUMNS_OF_EXAMPLE + ")" +
135-
" for the entry '" + name + "'");
136-
}
137-
if (examplesEntry != null && examplesEntry.length == COLUMN_TO_PG_EXAMPLE) {
138-
out.println("- [example in Playground]" + "(" + examplesEntry[COLUMN_TO_PG_EXAMPLE - 1] + ")");
128+
if (examplesEntry != null && examplesEntry.length > 2) {
129+
out.println("- [example in Playground]" + "(" + examplesEntry[2] + ")");
139130
}
140-
if (examplesEntry != null) {
131+
if (examplesEntry != null && examplesEntry.length > 1) {
141132
out.println("- java class:\t[" + moduleClass.getCanonicalName() + "](" + examplesEntry[1] + ")");
142133
}
143134
else {
@@ -213,6 +204,10 @@ private static void loadExamples() throws IOException {
213204
while ((line = bufferedReader.readLine()) != null) {
214205
final String[] tsv = line.split("\t");
215206
EXAMPLES_MAP.put(tsv[0], tsv);
207+
208+
if (tsv.length < 2) {
209+
System.err.println("Invalid command info: " + line);
210+
}
216211
}
217212
}
218213
}

0 commit comments

Comments
 (0)