MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / parseCommandLine

Method parseCommandLine

src/main/java/field/utility/Options.java:53–84  ·  view source on GitHub ↗
(String[] arg)

Source from the content-addressed store, hash-verified

51 static public String[] remainingArgs;
52
53 static public void parseCommandLine(String[] arg) {
54
55 int lastArg = 0;
56
57 for (int i = 0; i < arg.length; i++) {
58 if (arg[i].startsWith("-")) {
59 String q = arg[i].substring(1);
60
61 if (arg[i].startsWith("--")) q = arg[i].substring(2);
62
63 if (i < arg.length - 1) {
64 String v = arg[i + 1];
65
66 Number n = toNumber(v);
67 if (n != null)
68 options.o.put(new Dict.Prop<Number>(q), n);
69 else
70 options.o.put(new Dict.Prop<String>(q), v);
71 i += 1;
72 }
73 lastArg = i + 1;
74 }
75 }
76
77 if (lastArg < arg.length) {
78 remainingArgs = new String[arg.length - lastArg];
79 System.arraycopy(arg, lastArg, remainingArgs, 0, remainingArgs.length);
80 } else {
81 remainingArgs = new String[0];
82 }
83
84 }
85
86 static public Dict dict() {
87 return options.o;

Callers 2

mainMethod · 0.95
mainMethod · 0.95

Calls 2

toNumberMethod · 0.95
putMethod · 0.45

Tested by

no test coverage detected