1 | |
package com.lexicalscope.jewel.cli; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | 26 | class HelpMessageBuilderImpl implements HelpMessage { |
20 | 26 | private final StringBuilder message = new StringBuilder(); |
21 | |
|
22 | |
@Override public void noUsageInformation() { |
23 | 22 | message.append("The options available are:"); |
24 | 22 | } |
25 | |
|
26 | |
@Override public void hasUsageInformation(final String applicationName) { |
27 | 4 | hasUsageInformation(); |
28 | 4 | message.append(String.format("%s ", applicationName)); |
29 | 4 | } |
30 | |
|
31 | |
@Override public void hasUsageInformation() { |
32 | 4 | message.append("Usage: "); |
33 | 4 | } |
34 | |
|
35 | |
@Override public void hasOnlyOptionalOptions() { |
36 | 4 | message.append("["); |
37 | 4 | message.append("options"); |
38 | 4 | message.append("]"); |
39 | 4 | } |
40 | |
|
41 | |
@Override public void hasSomeMandatoryOptions() { |
42 | 0 | message.append("options"); |
43 | 0 | } |
44 | |
|
45 | |
@Override public void hasUnparsedMultiValuedOption(final String valueName) { |
46 | 4 | message.append(" "); |
47 | 4 | message.append(valueName); |
48 | 4 | message.append("..."); |
49 | 4 | } |
50 | |
|
51 | |
@Override public void hasUnparsedOption(final String valueName) { |
52 | 0 | message.append(" "); |
53 | 0 | message.append(valueName); |
54 | 0 | } |
55 | |
|
56 | 26 | private final String lineSeparator = System.getProperty("line.separator"); |
57 | 26 | private String separator = ""; |
58 | |
|
59 | |
@Override public void startOfOptions() { |
60 | 26 | message.append(lineSeparator); |
61 | 26 | } |
62 | |
|
63 | |
@Override public OptionHelpMessage option() { |
64 | 90 | message.append(separator).append("\t"); |
65 | 90 | separator = lineSeparator; |
66 | 90 | return new HelpMessageOptionSummaryBuilderImpl(message); |
67 | |
} |
68 | |
|
69 | |
@Override public void endOfOptions() { |
70 | |
|
71 | 26 | } |
72 | |
|
73 | |
@Override public String toString() { |
74 | 26 | return message.toString(); |
75 | |
} |
76 | |
} |