forked from I2P_Developers/i2p.i2p
Use getopt lib in SU3File (ticket #1173)
This commit is contained in:
@ -26,6 +26,8 @@ import java.util.Map;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import gnu.getopt.Getopt;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
@ -437,27 +439,37 @@ public class SU3File {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
List<String> a = new ArrayList<String>(Arrays.asList(args));
|
|
||||||
try {
|
try {
|
||||||
// defaults
|
// defaults
|
||||||
String stype = null;
|
String stype = null;
|
||||||
String ctype = null;
|
String ctype = null;
|
||||||
Iterator<String> iter = a.iterator();
|
boolean error = false;
|
||||||
String cmd = iter.next();
|
Getopt g = new Getopt("SU3File", args, "t:c:");
|
||||||
iter.remove();
|
int c;
|
||||||
for ( ; iter.hasNext(); ) {
|
while ((c = g.getopt()) != -1) {
|
||||||
String arg = iter.next();
|
switch (c) {
|
||||||
if (arg.equals("-t")) {
|
case 't':
|
||||||
iter.remove();
|
stype = g.getOptarg();
|
||||||
stype = iter.next();
|
break;
|
||||||
iter.remove();
|
|
||||||
} else if (arg.equals("-c")) {
|
case 'c':
|
||||||
iter.remove();
|
ctype = g.getOptarg();
|
||||||
ctype = iter.next();
|
break;
|
||||||
iter.remove();
|
|
||||||
}
|
case '?':
|
||||||
|
case ':':
|
||||||
|
default:
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ("showversion".equals(cmd)) {
|
|
||||||
|
int idx = g.getOptind();
|
||||||
|
String cmd = args[idx];
|
||||||
|
List<String> a = new ArrayList<String>(Arrays.asList(args).subList(idx + 1, args.length));
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
showUsageCLI();
|
||||||
|
} else if ("showversion".equals(cmd)) {
|
||||||
ok = showVersionCLI(a.get(0));
|
ok = showVersionCLI(a.get(0));
|
||||||
} else if ("sign".equals(cmd)) {
|
} else if ("sign".equals(cmd)) {
|
||||||
// speed things up by specifying a small PRNG buffer size
|
// speed things up by specifying a small PRNG buffer size
|
||||||
|
Reference in New Issue
Block a user