本文整理汇总了Java中org.kohsuke.args4j.CmdLineParser.setUsageWidth方法的典型用法代码示例。如果您正苦于以下问题:Java CmdLineParser.setUsageWidth方法的具体用法?Java CmdLineParser.setUsageWidth怎么用?Java CmdLineParser.setUsageWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kohsuke.args4j.CmdLineParser
的用法示例。
在下文中一共展示了CmdLineParser.setUsageWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printUsage
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private void printUsage(Object options) {
CmdLineParser parser = new CmdLineParser(options);
StringWriter sw = new StringWriter();
sw.append(USAGE_PREFIX + "\n");
sw.append(ALT_USAGE_PREFIX + " <source> <destination>\n");
sw.append(ALT_USAGE_PREFIX + " [OPTION]... [<value>...]\n\n");
sw.append("Options:");
System.out.println(sw.toString());
parser.setUsageWidth(100);
parser.printUsage(System.out);
}
示例2: parseArguments
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private void parseArguments(String args[]) {
CmdLineParser parser = new CmdLineParser(Rubus.this);
parser.setUsageWidth(80);
try {
// parse the arguments.
parser.parseArgument(args);
// you can parse additional arguments if you want.
// parser.parseArgument("more","args");
// after parsing arguments, you should check
// if enough arguments are given.
if (arguments.isEmpty())
throw new CmdLineException(parser, "No argument is provided");
} catch (CmdLineException e) {
System.err.println(e.getMessage());
System.err.println("java Rubus [options...] arguments...");
// print the list of available options
parser.printUsage(System.err);
System.err.println();
// print option sample. This is useful some time
System.err.println(" Example: java Rubus "
+ parser.printExample(ExampleMode.ALL));
return;
}
if (classPath != null && !classPath.isEmpty()) {
ClassFinder.setClassPath(classPath);
}
}
示例3: run
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
public void run(String[] args) {
CmdLineParser parser = new CmdLineParser(this);
parser.setUsageWidth(100);
try {
parser.parseArgument(args);
Pattern p = Pattern.compile("[0-9A-F]{8}");
if (!p.matcher(hex_devAddr).matches()) {
throw new CmdLineException("Invalid devAddr");
}
p = Pattern.compile("[0-9A-F]{32}");
if (!p.matcher(hex_nwkSKey).matches()) {
throw new CmdLineException("Invalid nwkSKey");
}
if (!p.matcher(hex_appSKey).matches()) {
throw new CmdLineException("Invalid appSKey");
}
p = Pattern.compile("[0-9A-F]{16}");
if (!p.matcher(hex_devEUI).matches()) {
throw new CmdLineException("Invalid devEUI");
}
if (!p.matcher(hex_gatewayEUI).matches()) {
throw new CmdLineException("Invalid gatewayEUI");
}
if (!hex.equals("")) {
p = Pattern.compile("([0-9A-F][0-9A-F]){1,125}");
if (!p.matcher(hex).matches()) {
throw new CmdLineException("Invalid hex payload");
}
}
} catch (CmdLineException ex) {
System.err.println(ex.getMessage());
parser.printUsage(System.err);
System.err.println();
return;
}
devAddr = hexStringToByteArray(hex_devAddr);
reverseArray(devAddr);
nwkSKey = hexStringToByteArray(hex_nwkSKey);
appSKey = hexStringToByteArray(hex_appSKey);
devEUI = hexStringToByteArray(hex_devEUI);
gatewayEUI = hexStringToByteArray(hex_gatewayEUI);
if (!hex.equals("")) {
payload = hexStringToByteArray(hex);
} else {
payload = txt.getBytes();
}
for (int i = 0; i < count; i++) {
doWork();
}
}
示例4: doMain
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
public void doMain(String[] args) throws IOException {
CmdLineParser parser = new CmdLineParser(this);
// if you have a wider console, you could increase the value;
// here 80 is also the default
parser.setUsageWidth(80);
try {
// parse the arguments.
parser.parseArgument(args);
} catch (CmdLineException e) {
// if there's a problem in the command line,
// you'll get this exception. this will report
// an error message.
System.err.println(e.getMessage());
System.err.println("java SimpleBot [options...] arguments...");
// print the list of available options
parser.printUsage(System.err);
System.err.println();
// print option sample. This is useful some time
System.err.println(" Example: java SampleMain" + parser.printExample(OptionHandlerFilter.REQUIRED));
return;
}
OkHttpClient client = new OkHttpClient();
final MMBot bot = MMBot.logIn(client, this.mattermostServer, this.login, this.pwd);
for (String bugzilla : bugzillas) {
bot.onMessage(new RespondWithBugzillaReferences(bugzilla));
}
for (String gerrit : gerrits) {
bot.onMessage(new RespondWithGerritReferences(gerrit));
}
if (twitterAccessToken != null && twitterAccessTokenSecret != null && twitterConsumerKey != null
&& twitterConsumerSecret != null) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(this.twitterConsumerKey).setOAuthConsumerSecret(this.twitterConsumerSecret)
.setOAuthAccessToken(this.twitterAccessToken)
.setOAuthAccessTokenSecret(this.twitterAccessTokenSecret);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
bot.onMessage(new RespondWithTwitterReferences(twitter));
}
bot.onMessage(new RespondWithGiphyAnimation());
bot.onMessage(new RespondWithPullRequestsReferences());
bot.listen();
}
示例5: doMain
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
public void doMain(String[] args) throws Exception {
CmdLineParser parser = new CmdLineParser(this);
parser.setUsageWidth(120);
try {
parser.parseArgument(args);
FinancialInstitutionDataStore dataStore = new LocalResourceFIDataStore();
FinancialInstitutionData data = null;
for (FinancialInstitutionData item : dataStore.getInstitutionDataList()) {
if (fid.equals(item.getFinancialInstitutionId())) {
data = item;
break;
}
}
if (data == null) {
exit("Unknown financial institution: " + fid);
}
OFXV1Connection connection = new OFXV1Connection();
FinancialInstitution fi = new FinancialInstitutionImpl(data, connection);
Collection<AccountProfile> profiles = fi.readAccountProfiles(username, password);
AccountInfoResponse accountsElement = new AccountInfoResponse();
accountsElement.setAccounts(profiles);
AggregateMarshaller marshaller = new AggregateMarshaller();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
OFXWriter writer = new OFXV1Writer(bytes);
((OFXV1Writer)writer).setWriteAttributesOnNewLine(true);
if (v2) {
writer = new OFXV2Writer(bytes);
}
marshaller.marshal(accountsElement, writer);
writer.close();
System.out.println(bytes.toString());
System.out.flush();
if (out != null) {
FileOutputStream stream = new FileOutputStream(out);
stream.write(bytes.toByteArray());
stream.flush();
stream.close();
}
}
catch (CmdLineException e) {
invalidArgs(parser, e);
}
}