本文整理汇总了Java中jargs.gnu.CmdLineParser.addStringOption方法的典型用法代码示例。如果您正苦于以下问题:Java CmdLineParser.addStringOption方法的具体用法?Java CmdLineParser.addStringOption怎么用?Java CmdLineParser.addStringOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jargs.gnu.CmdLineParser
的用法示例。
在下文中一共展示了CmdLineParser.addStringOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseCmd
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
public void parseCmd(String[] args){
//System.out.println("*** running ArduinoClient standalone WparseCmd");
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option debugOption = parser.addBooleanOption('X', "debug");
CmdLineParser.Option arduinoServerOption = parser.addStringOption('s', "arduinoServer");
try {
parser.parse(args);
}
catch ( CmdLineParser.OptionException e ) {
System.err.println(e.getMessage());
System.out.println("parseCmd had an error\n"+ usage );
System.exit(2);
}
// String portname = args[0]; // e.g. "/dev/cu.KeySerial1", or "COM5" or "192.168.1.1:5002"
arduinoServer = (((String)parser.getOptionValue(arduinoServerOption)));
Boolean debugBool = (Boolean)parser.getOptionValue(debugOption,new Boolean(false));
setDebug(debugBool.booleanValue());
//System.out.println("debug is ("+isDebug()+")");
//System.out.println("*** end of parseCmd");
}
示例2: buildParser
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
/**
* Create a new command line parser.
*
* @return command line parser
*/
public static CmdLineParser buildParser() {
CmdLineParser parser = new CmdLineParser();
HELP_ARG = parser.addBooleanOption(HELP);
SIGN_ARG = parser.addBooleanOption(SIGN);
VALIDATE_ARG = parser.addBooleanOption(VALIDATE);
INPUT_FILE_ARG = parser.addStringOption(INPUT_FILE);
KEYSTORE_ARG = parser.addStringOption(KEYSTORE);
KEYSTORE_TYPE_ARG = parser.addStringOption(KEYSTORE_TYPE);
KEYSTORE_PASS_ARG = parser.addStringOption(KEYSTORE_PASS);
ALIAS_ARG = parser.addStringOption(ALIAS);
KEY_PASS_ARG = parser.addStringOption(KEY_PASS);
OUTPUT_FILE_ARG = parser.addStringOption(OUTPUT_FILE);
return parser;
}
示例3: testStandardOptions
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
public void testStandardOptions() throws Exception {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option verbose = parser.addBooleanOption('v', "verbose");
CmdLineParser.Option size = parser.addIntegerOption('s', "size");
CmdLineParser.Option name = parser.addStringOption('n', "name");
CmdLineParser.Option fraction = parser.addDoubleOption('f', "fraction");
CmdLineParser.Option missing = parser.addBooleanOption('m', "missing");
CmdLineParser.Option careful = parser.addBooleanOption("careful");
CmdLineParser.Option bignum = parser.addLongOption('b', "bignum");
assertEquals(null, parser.getOptionValue(size));
Long longValue = new Long(new Long(Integer.MAX_VALUE).longValue() + 1);
parser.parse(new String[] { "-v", "--size=100", "-b",
longValue.toString(), "-n", "foo", "-f", "0.1", "rest" },
Locale.US);
assertEquals(null, parser.getOptionValue(missing));
assertEquals(Boolean.TRUE, parser.getOptionValue(verbose));
assertEquals(100, ((Integer) parser.getOptionValue(size)).intValue());
assertEquals("foo", parser.getOptionValue(name));
assertEquals(longValue, parser.getOptionValue(bignum));
assertEquals(0.1, ((Double) parser.getOptionValue(fraction))
.doubleValue(), 0.1e-6);
assertArrayEquals(new String[]{"rest"}, parser.getRemainingArgs());
}
示例4: process_cmdline_args
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
private static void process_cmdline_args(String[] args) {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option optionCodons = parser.addStringOption('c', "codons");
CmdLineParser.Option optionMatrixFile = parser.addStringOption('m', "matrix-file");
CmdLineParser.Option optionServerIPname = parser.addStringOption('s', "server");
CmdLineParser.Option optionAuto = parser.addBooleanOption('a', "autogen");
CmdLineParser.Option optionCodonLength = parser.addIntegerOption('n', "protein-length");
CmdLineParser.Option optionIterCount = parser.addIntegerOption('r', "iteration");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
printUsage();
System.exit(2);
}
clientCodons = (String) parser.getOptionValue(optionCodons, new String("A"));
matrixFile = (String) parser.getOptionValue(optionMatrixFile, new String("matrices/Simple"));
autogen = (Boolean) parser.getOptionValue(optionAuto, false);
n = ((Integer) parser.getOptionValue(optionCodonLength, new Integer(100))).intValue();
ProgClient.serverIPname = (String) parser.getOptionValue(optionServerIPname, new String("localhost"));
Program.iterCount = ((Integer) parser.getOptionValue(optionIterCount, new Integer(1))).intValue();
}
示例5: process_cmdline_args
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
private static void process_cmdline_args(String[] args) {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option optionCodons = parser.addStringOption('c', "codons");
CmdLineParser.Option optionMatrixFile = parser.addStringOption('m', "matrix-file");
CmdLineParser.Option optionAuto = parser.addBooleanOption('a', "autogen");
CmdLineParser.Option optionCodonLength = parser.addIntegerOption('n', "protein-length");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
printUsage();
System.exit(2);
}
serverCodons = (String) parser.getOptionValue(optionCodons, new String("A"));
matrixFile = (String) parser.getOptionValue(optionMatrixFile, new String("matrices/blosum20x20"));
autogen = (Boolean) parser.getOptionValue(optionAuto, false);
n = ((Integer) parser.getOptionValue(optionCodonLength, new Integer(100))).intValue();
}
示例6: process_cmdline_args
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
private static void process_cmdline_args(String[] args) {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option optionServerIPname = parser.addStringOption('s', "server");
CmdLineParser.Option optionAuto = parser.addBooleanOption('a', "autogen");
CmdLineParser.Option optionDNALength = parser.addIntegerOption('n', "DNALength");
CmdLineParser.Option optionIterCount = parser.addIntegerOption('r', "iteration");
CmdLineParser.Option optionSigma = parser.addIntegerOption('g', "sigma");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
printUsage();
System.exit(2);
}
autogen = (Boolean) parser.getOptionValue(optionAuto, false);
n = ((Integer) parser.getOptionValue(optionDNALength, new Integer(100))).intValue();
ProgClient.serverIPname = (String) parser.getOptionValue(optionServerIPname, new String("localhost"));
Program.iterCount = ((Integer) parser.getOptionValue(optionIterCount, new Integer(10))).intValue();
EditDistanceCommon.sigma = ((Integer) parser.getOptionValue(optionSigma, new Integer(2))).intValue();
}
示例7: process_cmdline_args
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
private static void process_cmdline_args(String[] args) {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option optionKeyFile = parser.addStringOption('k', "key-file");
CmdLineParser.Option optionAuto = parser.addBooleanOption('a', "autogen");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
printUsage();
System.exit(2);
}
keyFile = (String) parser.getOptionValue(optionKeyFile, new String("key"));
autogen = (Boolean) parser.getOptionValue(optionAuto, false);
}
示例8: process_cmdline_args
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
private static void process_cmdline_args(String[] args) {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option optionServerIPname = parser.addStringOption('s', "server");
CmdLineParser.Option optionAuto = parser.addBooleanOption('a', "autogen");
CmdLineParser.Option optionIterCount = parser.addIntegerOption('r', "iteration");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
printUsage();
System.exit(2);
}
autogen = (Boolean) parser.getOptionValue(optionAuto, false);
ProgClient.serverIPname = (String) parser.getOptionValue(optionServerIPname, new String("localhost"));
Program.iterCount = ((Integer) parser.getOptionValue(optionIterCount, new Integer(1))).intValue();
}
示例9: process_cmdline_args
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
private static void process_cmdline_args(String[] args) {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option optionServerIPname = parser.addStringOption('s', "server");
CmdLineParser.Option optionBitLength = parser.addIntegerOption('n', "bit-Length");
CmdLineParser.Option optionIterCount = parser.addIntegerOption('r', "iteration");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
printUsage();
System.exit(2);
}
ProgClient.serverIPname = (String) parser.getOptionValue(optionServerIPname, new String("localhost"));
Program.iterCount = ((Integer) parser.getOptionValue(optionIterCount, new Integer(1))).intValue();
}
示例10: process_cmdline_args
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
private static void process_cmdline_args(String[] args) {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option optionServerIPname = parser.addStringOption('s', "server");
CmdLineParser.Option optionBitLength = parser.addIntegerOption('n', "bit-Length");
CmdLineParser.Option optionIterCount = parser.addIntegerOption('r', "iteration");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
printUsage();
System.exit(2);
}
n = ((Integer) parser.getOptionValue(optionBitLength, new Integer(900))).intValue();
ProgClient.serverIPname = (String) parser.getOptionValue(optionServerIPname, new String("localhost"));
Program.iterCount = ((Integer) parser.getOptionValue(optionIterCount, new Integer(5))).intValue();
}
示例11: parseCmd
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
public void parseCmd(String[] args){
//System.out.println("*** start of AudioLocalizerClient WparseCmd");
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option debugOption = parser.addBooleanOption('X', "debug");
CmdLineParser.Option localizerServerOption = parser.addStringOption('l', "localizerServer");
CmdLineParser.Option localizerPortNumOption = parser.addIntegerOption('p', "localizerPortNum");
try {
parser.parse(args);
}
catch ( CmdLineParser.OptionException e ) {
System.err.println(e.getMessage());
System.out.println("parseCmd had an error\n"+ usage );
System.exit(2);
}
// String portname = args[0]; // e.g. "/dev/cu.KeySerial1", or "COM5" or "192.168.1.1"
setLocalizerServer(((String)parser.getOptionValue(localizerServerOption)));
setLocalizerPortNum(((Integer)parser.getOptionValue(localizerPortNumOption, getLocalizerPortNum())).intValue());
// String cmd = args[1+argOffset];
Boolean debugBool = (Boolean)parser.getOptionValue(debugOption,new Boolean(false));
setDebug(debugBool.booleanValue());
System.out.println("debug is ("+isDebug()+")");
//System.out.println("*** end of parseCmd");
}
示例12: main
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
public static void main(String args[]) {
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option inFile = parser.addStringOption('f', "file");
CmdLineParser.Option outFile = parser.addStringOption('o', "output");
CmdLineParser.Option window = parser.addIntegerOption('w', "window");
CmdLineParser.Option step = parser.addIntegerOption('s', "step");
try {
parser.parse(args);
}
catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
printUsage();
System.exit(2);
}
windowSize =
(Integer) parser.getOptionValue(window, 5);
windowStep =
(Integer) parser.getOptionValue(step, 1);
SequenceGC sequence = new SequenceGC();
String inPath = (String) parser.getOptionValue(inFile);
String outPath = (String) parser.getOptionValue(outFile);
if (!(inPath == null))
sequence.ProcessPath(inPath, outPath);
else
printUsage();
}
示例13: testMissingValueForStringOption
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
public void testMissingValueForStringOption() throws Exception {
CmdLineParser parser = new CmdLineParser();
parser.addBooleanOption('v', "verbose");
parser.addStringOption('c', "config");
try {
parser.parse(new String[] {"-v", "-c"});
fail();
} catch (CmdLineParser.IllegalOptionValueException e) {
}
}
示例14: parseArgs
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
public HashMap<String, Object> parseArgs(String[] args) throws IOException {
printSplashScreen();
HashMap<String, Object> result = new HashMap<String, Object>();
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option destinationFolder = parser.addStringOption('d', "destFolder");
CmdLineParser.Option sourceFolder = parser.addStringOption('s', "sourceFolder");
CmdLineParser.Option tacType = parser.addStringOption('t', "tacType");
CmdLineParser.Option removeSourceFiles = parser.addBooleanOption('r', "removeSourceFiles");
CmdLineParser.Option silentMode = parser.addBooleanOption("silent");
CmdLineParser.Option replaceMode = parser.addBooleanOption("replace");
try {
parser.parse(args);
} catch (CmdLineParser.OptionException e) {
System.err.println(e.getMessage());
exit(2, "");
}
destinationFolderArg = (String) parser.getOptionValue(destinationFolder, System.getProperty("user.home") + "/destination-folder");
if (destinationFolderArg == null) {
exit(3, "Please provide parameter -d,--destFolder destination folder path");
}
result.put("destinationFolderArg", destinationFolderArg);
sourceFolderArg = (String) parser.getOptionValue(sourceFolder);
if (sourceFolderArg == null) {
exit(4, "Please provide parameter -s,--sourceFolder source folder path");
}
result.put("sourceFolderArg", sourceFolderArg);
tacTypeArg = (String) parser.getOptionValue(tacType);
if (noValidTacType(tacTypeArg)) {
exit(5, "Please provide parameter -t,--tacType [METAR | TAF | SIGMET | SPECI]");
}
result.put("tacTypeArg", tacTypeArg);
removeSourceFilesArg = (Boolean) parser.getOptionValue(removeSourceFiles, Boolean.FALSE);
if (removeSourceFilesArg == null) {
exit(6, "Please provide parameter -r,--removeSourceFiles");
}
result.put("removeSourceFilesArg", removeSourceFilesArg);
Boolean silentOptionValue = (Boolean) parser.getOptionValue(silentMode, Boolean.FALSE);
if (silentOptionValue == null) {
silentOptionValue = false;
}
result.put("silent", silentOptionValue);
Boolean replaceOptionValue = (Boolean) parser.getOptionValue(replaceMode, Boolean.FALSE);
if (replaceOptionValue == null) {
replaceOptionValue = false;
}
result.put("replace", replaceOptionValue);
return result;
}
示例15: parseCmd
import jargs.gnu.CmdLineParser; //导入方法依赖的package包/类
public void parseCmd(String[] args){
System.out.println("*** start of WatchVideo WparseCmd");
CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option debugOption = parser.addBooleanOption('X', "debug");
// CmdLineParser.Option verboseOption = parser.addBooleanOption('W', "Verbose");
CmdLineParser.Option widthOption = parser.addIntegerOption('x', "width");
CmdLineParser.Option heightOption = parser.addIntegerOption('y', "height");
CmdLineParser.Option videoServerOption = parser.addStringOption("videoServer");
CmdLineParser.Option videoPortNumOption = parser.addIntegerOption("videoPortNum");
CmdLineParser.Option thresholdOption = parser.addIntegerOption('t', "threshold");
CmdLineParser.Option hwHandShakeOption = parser.addBooleanOption("nohwhandshake");
CmdLineParser.Option colorOption = parser.addBooleanOption('c', "color");
CmdLineParser.Option roborealmOption = parser.addBooleanOption('R', "roborealm");
try {
parser.parse(args);
}
catch ( CmdLineParser.OptionException e ) {
System.err.println(e.getMessage());
System.out.println("parseCmd had an error\n"+ usage );
System.exit(2);
}
// String portname = args[0]; // e.g. "/dev/cu.KeySerial1", or "COM5" or "192.168.1.1"
setThresholdOverride(((Integer)parser.getOptionValue(thresholdOption, getThresholdOverride())).intValue());
setWidth(((Integer)parser.getOptionValue(widthOption,getWidth())).intValue());
setHeight(((Integer)parser.getOptionValue(heightOption,getHeight())).intValue());
setVideoServer(((String)parser.getOptionValue(videoServerOption)));
setVideoPortNum(((Integer)parser.getOptionValue(videoPortNumOption, getVideoPortNum())).intValue());
// String cmd = args[1+argOffset];
Boolean debugBool = (Boolean)parser.getOptionValue(debugOption,new Boolean(false));
setDebug(debugBool.booleanValue());
System.out.println("debug is ("+isDebug()+")");
Boolean hwHandShakeBool = (Boolean)parser.getOptionValue(hwHandShakeOption, new Boolean(false));
setThresholdOverride((Integer)parser.getOptionValue(thresholdOption, new Integer(0)));
System.out.println("thresholdOverride is " + getThresholdOverride());
color = (Boolean)parser.getOptionValue(colorOption, new Boolean(false));
roborealm = (Boolean)parser.getOptionValue(roborealmOption, new Boolean(false));
System.out.println("color mode is " + color + ", roborealm mode is " + roborealm);
System.out.println("*** end of parseCmd");
}