use of com.beust.jcommander.ParameterException in project drill by apache.
the class QuerySubmitter method main.
public static void main(String[] args) throws Exception {
QuerySubmitter submitter = new QuerySubmitter();
Options o = new Options();
JCommander jc = null;
try {
jc = new JCommander(o, args);
jc.setProgramName("./submit_plan");
} catch (ParameterException e) {
System.out.println(e.getMessage());
String[] valid = { "-f", "file", "-t", "physical" };
new JCommander(o, valid).usage();
System.exit(-1);
}
if (o.help) {
jc.usage();
System.exit(0);
}
System.exit(submitter.submitQuery(o.location, o.queryString, o.planType, o.zk, o.local, o.bits, o.format, o.width));
}
use of com.beust.jcommander.ParameterException in project druid by druid-io.
the class TestNG method privateMain.
/**
* <B>Note</B>: this method is not part of the public API and is meant for internal usage only.
*/
public static TestNG privateMain(String[] argv, ITestListener listener) {
TestNG result = new TestNG();
if (null != listener) {
result.addListener(listener);
}
//
try {
CommandLineArgs cla = new CommandLineArgs();
m_jCommander = new JCommander(cla, argv);
validateCommandLineParameters(cla);
result.configure(cla);
} catch (ParameterException ex) {
exitWithError(ex.getMessage());
}
//
try {
result.run();
} catch (TestNGException ex) {
if (TestRunner.getVerbose() > 1) {
ex.printStackTrace(System.out);
} else {
error(ex.getMessage());
}
result.setStatus(HAS_FAILURE);
}
return result;
}
use of com.beust.jcommander.ParameterException in project walle by Meituan-Dianping.
the class Main method main.
public static void main(final String[] args) throws Exception {
final Map<String, IWalleCommand> subCommandList = new HashMap<String, IWalleCommand>();
subCommandList.put("show", new ShowCommand());
subCommandList.put("rm", new RemoveCommand());
subCommandList.put("put", new WriteChannelCommand());
subCommandList.put("batch", new WriteChannelsCommand());
final WalleCommandLine walleCommandLine = new WalleCommandLine();
final JCommander commander = new JCommander(walleCommandLine);
for (Map.Entry<String, IWalleCommand> commandEntry : subCommandList.entrySet()) {
commander.addCommand(commandEntry.getKey(), commandEntry.getValue());
}
try {
commander.parse(args);
} catch (ParameterException e) {
System.out.println(e.getMessage());
commander.usage();
System.exit(1);
return;
}
walleCommandLine.parse(commander);
final String parseCommand = commander.getParsedCommand();
if (parseCommand != null) {
subCommandList.get(parseCommand).parse();
}
}
use of com.beust.jcommander.ParameterException in project pulsar by yahoo.
the class CliCommand method validatePersistentTopic.
String validatePersistentTopic(List<String> params) {
String destination = checkArgument(params);
DestinationName ds = DestinationName.get(destination);
if (ds.getDomain() != DestinationDomain.persistent) {
throw new ParameterException("Need to provide a persistent topic name");
}
return ds.toString();
}
use of com.beust.jcommander.ParameterException in project pulsar by yahoo.
the class CmdNamespaceIsolationPolicy method createNamespaceIsolationData.
private NamespaceIsolationData createNamespaceIsolationData(List<String> namespaces, List<String> primary, List<String> secondary, String autoFailoverPolicyTypeName, Map<String, String> autoFailoverPolicyParams) {
// validate
namespaces = validateList(namespaces);
if (namespaces.isEmpty()) {
throw new ParameterException("unable to parse namespaces parameter list: " + namespaces);
}
primary = validateList(primary);
if (primary.isEmpty()) {
throw new ParameterException("unable to parse primary parameter list: " + namespaces);
}
secondary = validateList(secondary);
// System.out.println("namespaces = " + namespaces);
// System.out.println("primary = " + primary);
// System.out.println("secondary = " + secondary);
// System.out.println("autoFailoverPolicyTypeName = " + autoFailoverPolicyTypeName);
// System.out.println("autoFailoverPolicyParams = " + autoFailoverPolicyParams);
NamespaceIsolationData nsIsolationData = new NamespaceIsolationData();
if (namespaces != null) {
nsIsolationData.namespaces = namespaces;
}
if (primary != null) {
nsIsolationData.primary = primary;
}
if (secondary != null) {
nsIsolationData.secondary = secondary;
}
nsIsolationData.auto_failover_policy = new AutoFailoverPolicyData();
nsIsolationData.auto_failover_policy.policy_type = AutoFailoverPolicyType.fromString(autoFailoverPolicyTypeName);
nsIsolationData.auto_failover_policy.parameters = autoFailoverPolicyParams;
// validation if necessary
if (nsIsolationData.auto_failover_policy.policy_type == AutoFailoverPolicyType.min_available) {
// ignore
boolean error = true;
String[] expectParamKeys = { "min_limit", "usage_threshold" };
if (autoFailoverPolicyParams.size() == expectParamKeys.length) {
for (String paramKey : expectParamKeys) {
if (!autoFailoverPolicyParams.containsKey(paramKey)) {
break;
}
}
error = false;
}
if (error) {
throw new ParameterException("Unknown auto failover policy params specified : " + autoFailoverPolicyParams);
}
} else {
// either we don't handle the new type or user has specified a bad type
throw new ParameterException("Unknown auto failover policy type specified : " + autoFailoverPolicyTypeName);
}
return nsIsolationData;
}
Aggregations