niagara-ax/modules/cfr_output/com/tridium/util/CommandLineArguments.java
2026-03-17 13:31:18 -07:00

112 lines
3.2 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package com.tridium.util;
import java.util.Vector;
public class CommandLineArguments {
public final String[] parameters;
public final String[] options;
public final String[] optionValues;
public boolean hasHelpOption() {
if (this.hasOption("?")) {
return true;
}
if (this.hasOption("help")) {
return true;
}
return this.hasOption("usage");
}
public boolean hasOption(String string) {
int n = 0;
while (n < this.options.length) {
if (this.options[n].equals(string)) {
return true;
}
++n;
}
return false;
}
public String getOption(String string) {
return this.getOption(string, null);
}
public String getOption(String string, String string2) {
int n = 0;
while (n < this.options.length) {
if (this.options[n].equals(string)) {
if (this.optionValues[n] == null) break;
return this.optionValues[n];
}
++n;
}
return string2;
}
public int getIntOption(String string, int n) {
int n2 = 0;
while (n2 < this.options.length) {
if (this.options[n2].equals(string)) {
return Integer.parseInt(this.optionValues[n2]);
}
++n2;
}
return n;
}
public void dump() {
int n = 0;
while (n < this.parameters.length) {
System.out.println(this.parameters[n] + " [" + n + ']');
++n;
}
n = 0;
while (n < this.options.length) {
if (this.optionValues[n] == null) {
System.out.println("-" + this.options[n]);
} else {
System.out.println("-" + this.options[n] + ':' + this.optionValues[n]);
}
++n;
}
}
public static void main(String[] stringArray) {
new CommandLineArguments(stringArray).dump();
}
public CommandLineArguments(String[] stringArray) {
Vector<String> vector = new Vector<String>();
Vector<String> vector2 = new Vector<String>();
Vector<String> vector3 = new Vector<String>();
int n = 0;
while (n < stringArray.length) {
String string = stringArray[n];
if (string.length() > 1 && string.charAt(0) == '-') {
int n2 = (string = string.substring(1)).indexOf(58);
if (n2 > 0) {
vector2.addElement(string.substring(0, n2));
vector3.addElement(string.substring(n2 + 1));
} else {
vector2.addElement(string);
vector3.addElement(null);
}
} else {
vector.addElement(string);
}
++n;
}
this.parameters = new String[vector.size()];
vector.copyInto(this.parameters);
this.options = new String[vector2.size()];
vector2.copyInto(this.options);
this.optionValues = new String[vector3.size()];
vector3.copyInto(this.optionValues);
}
}