use of com.beust.jcommander.JCommander in project bytecode-viewer by Konloch.
the class ProcyonDecompiler method getDecompilerSettings.
public DecompilerSettings getDecompilerSettings() {
CommandLineOptions options = new CommandLineOptions();
JCommander jCommander = new JCommander(options);
String[] args = new String[Settings.values().length * 2];
int index = 0;
for (the.bytecode.club.bytecodeviewer.DecompilerSettings.Setting setting : Settings.values()) {
args[index++] = "--" + setting.getParam();
args[index++] = String.valueOf(getSettings().isSelected(setting));
}
jCommander.parse(args);
DecompilerSettings settings = new DecompilerSettings();
settings.setFlattenSwitchBlocks(options.getFlattenSwitchBlocks());
settings.setForceExplicitImports(!options.getCollapseImports());
settings.setForceExplicitTypeArguments(options.getForceExplicitTypeArguments());
settings.setRetainRedundantCasts(options.getRetainRedundantCasts());
settings.setShowSyntheticMembers(options.getShowSyntheticMembers());
settings.setExcludeNestedTypes(options.getExcludeNestedTypes());
settings.setOutputDirectory(options.getOutputDirectory());
settings.setIncludeLineNumbersInBytecode(options.getIncludeLineNumbers());
settings.setRetainPointlessSwitches(options.getRetainPointlessSwitches());
settings.setUnicodeOutputEnabled(options.isUnicodeOutputEnabled());
settings.setMergeVariables(options.getMergeVariables());
settings.setShowDebugLineNumbers(options.getShowDebugLineNumbers());
settings.setSimplifyMemberReferences(options.getSimplifyMemberReferences());
settings.setDisableForEachTransforms(options.getDisableForEachTransforms());
settings.setTypeLoader(new InputTypeLoader());
if (options.isRawBytecode()) {
settings.setLanguage(Languages.bytecode());
} else if (options.isBytecodeAst()) {
settings.setLanguage(options.isUnoptimized() ? Languages.bytecodeAstUnoptimized() : Languages.bytecodeAst());
}
return settings;
}
use of com.beust.jcommander.JCommander in project calcite-avatica by apache.
the class StandaloneServer method main.
public static void main(String[] args) {
final StandaloneServer server = new StandaloneServer();
JCommander jc = new JCommander(server, args);
if (server.help) {
jc.usage();
Unsafe.systemExit(ExitCodes.USAGE.ordinal());
return;
}
server.start();
// Try to clean up when the server is stopped.
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
LOG.info("Stopping server");
server.stop();
LOG.info("Server stopped");
}
}));
try {
server.join();
} catch (InterruptedException e) {
// Reset interruption
Thread.currentThread().interrupt();
// And exit now.
return;
}
}
use of com.beust.jcommander.JCommander in project drill by apache.
the class DumpCat method main.
public static void main(String[] args) throws Exception {
final DumpCat dumpCat = new DumpCat();
final Options o = new Options();
JCommander jc = null;
try {
jc = new JCommander(o, args);
jc.setProgramName("./drill_dumpcat");
} catch (ParameterException e) {
System.out.println(e.getMessage());
final String[] valid = { "-f", "file" };
new JCommander(o, valid).usage();
System.exit(-1);
}
if (o.help) {
jc.usage();
System.exit(0);
}
/*Check if dump file exists*/
final File file = new File(o.location);
if (!file.exists()) {
System.out.println(String.format("Trace file %s not created", o.location));
System.exit(-1);
}
try (final FileInputStream input = new FileInputStream(file.getAbsoluteFile())) {
if (o.batch < 0) {
dumpCat.doQuery(input);
} else {
dumpCat.doBatch(input, o.batch, o.include_headers);
}
}
}
use of com.beust.jcommander.JCommander 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.JCommander in project drill by apache.
the class StartupOptions method parse.
public static StartupOptions parse(String[] cliArgs) {
logger.debug("Parsing arguments.");
StartupOptions args = new StartupOptions();
JCommander jc = new JCommander(args, cliArgs);
if (args.help) {
jc.usage();
System.exit(0);
}
return args;
}
Aggregations