MCPcopy Create free account
hub / github.com/mozilla/rhino / processOptions

Method processOptions

examples/src/main/java/Shell.java:91–109  ·  view source on GitHub ↗

Parse arguments. @param cx the current Context for this thread @param args the array of arguments @return the options as String[]

(Context cx, String args[])

Source from the content-addressed store, hash-verified

89 * @return the options as String[]
90 */
91 public static String[] processOptions(Context cx, String args[]) {
92 for (int i = 0; i < args.length; i++) {
93 String arg = args[i];
94 if (!arg.startsWith("-")) {
95 String[] result = new String[args.length - i];
96 for (int j = i; j < args.length; j++) result[j - i] = args[j];
97 return result;
98 }
99 if (arg.equals("-version")) {
100 if (++i == args.length) usage(arg);
101 double d = Context.toNumber(args[i]);
102 if (Double.isNaN(d)) usage(arg);
103 cx.setLanguageVersion((int) d);
104 continue;
105 }
106 usage(arg);
107 }
108 return new String[0];
109 }
110
111 /** Print a usage message. */
112 private static void usage(String s) {

Callers 1

mainMethod · 0.95

Calls 5

usageMethod · 0.95
toNumberMethod · 0.95
equalsMethod · 0.45
isNaNMethod · 0.45
setLanguageVersionMethod · 0.45

Tested by

no test coverage detected