Skip to content

Commit ae5c361

Browse files
committed
made list of otuput and list of languages dynamic in usage text
1 parent f97bc64 commit ae5c361

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

org/w3c/css/css/CssValidator.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.w3c.css.util.ApplContext;
1313
import org.w3c.css.util.HTTPURL;
14+
import org.w3c.css.util.Messages;
1415
import org.w3c.css.util.Util;
1516
import org.w3c.tools.resources.ProtocolException;
1617
import org.w3c.www.mime.MimeType;
@@ -23,6 +24,7 @@
2324
import java.net.URL;
2425
import java.util.ArrayList;
2526
import java.util.Arrays;
27+
import java.util.Collections;
2628
import java.util.HashMap;
2729
import java.util.Iterator;
2830

@@ -94,7 +96,7 @@ public static void main(String args[])
9496
// first, we get the parameters and create an application context
9597
try {
9698
style.getParams(args);
97-
style.ac = new ApplContext((String) style.params.get("lang"));
99+
style.ac = new ApplContext(style.params.get("lang"));
98100
System.err.println(style.params);
99101
} catch (Exception e) {
100102
System.out.println("Usage: java org.w3c.css.css.CssValidator " +
@@ -115,24 +117,40 @@ public static void main(String args[])
115117
"projection, screen, tty, tv, presentation");
116118
System.out.println("\t-output OUTPUT, --output=OUTPUT");
117119
System.out.println("\t\tPrints the result in the selected format");
118-
System.out.println("\t\tPossible values for OUTPUT are text (default), xhtml, " +
119-
"html (same result as xhtml), soap12");
120+
System.out.println("\t\tPossible values for OUTPUT are ");
121+
System.out.print("\t\t");
122+
System.out.println(StyleSheetGenerator.printAvailableFormatList("text"));
120123
System.out.println("\t-lang LANG, --lang=LANG");
121124
System.out.println("\t\tPrints the result in the specified language");
122-
System.out.println("\t\tPossible values for LANG are " +
123-
"de, en (default), es, fr, ja, ko, nl, zh-cn, pl, it");
125+
System.out.println("\t\tPossible values for LANG are ");
126+
ArrayList<String> languages_name = Messages.languages_name;
127+
Collections.sort(languages_name);
128+
boolean isFirst = true;
129+
for (String s : languages_name) {
130+
if (!isFirst) {
131+
System.out.print(", ");
132+
} else {
133+
System.out.print("\t\t");
134+
isFirst = false;
135+
}
136+
System.out.print(s);
137+
if ("en".equals(s)) {
138+
System.out.print(" (default)");
139+
}
140+
}
141+
System.out.println("");
124142
System.out.println("\t-warning WARN, --warning=WARN");
125143
System.out.println("\t\tWarnings verbosity level");
126144
System.out.println("\t\tPossible values for WARN are -1 (no " +
127-
"warning), 0, 1, 2 (default, all the warnings");
145+
"warning), 0, 1, 2 (default, all the warnings)");
128146
System.out.println("\t-vextwarning true, --vextwarning=true");
129147
System.out.println("\t\tTreat Vendor Extensions as warnings");
130148
System.out.println("\t\tPossible values for vextwarning are true or false " +
131-
"(default, is false");
149+
"(default)");
132150
System.out.println();
133151
System.out.println("URL");
134152
System.out.println("\tURL can either represent a distant " +
135-
"web resource (http://) or a local file (file:/)");
153+
"web resource (https://) or a local file (file:/)");
136154
System.out.println();
137155
System.out.println("EXIT STATUS");
138156
System.out.println("return 0 on success, 1 for fatal errors, 10 to 110 for " +

org/w3c/css/css/StyleSheetGenerator.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.nio.file.FileSystems;
3131
import java.text.SimpleDateFormat;
3232
import java.util.ArrayList;
33+
import java.util.Collections;
3334
import java.util.Date;
3435
import java.util.Enumeration;
3536
import java.util.HashMap;
@@ -245,6 +246,25 @@ public final static void printAvailableFormat(PrintWriter out) {
245246
out.flush();
246247
}
247248

249+
public static String printAvailableFormatList(String def) {
250+
Enumeration<?> e = availableFormat.propertyNames();
251+
StringBuilder sb = new StringBuilder();
252+
ArrayList<String> t = (ArrayList<String>) Collections.list(e);
253+
Collections.sort(t);
254+
boolean isFirst = true;
255+
for (String s : t) {
256+
if (!isFirst) {
257+
sb.append(", ");
258+
}
259+
isFirst = false;
260+
sb.append(s);
261+
if (s.equals(def)) {
262+
sb.append(" (default)");
263+
}
264+
}
265+
return sb.toString();
266+
}
267+
248268

249269
/**
250270
* Test if <tt>document</tt> is an available output

0 commit comments

Comments
 (0)