Search in sources :

Example 26 with JCommander

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;
}
Also used : InputTypeLoader(com.strobel.assembler.InputTypeLoader) CommandLineOptions(com.strobel.decompiler.CommandLineOptions) JCommander(com.beust.jcommander.JCommander) DecompilerSettings(com.strobel.decompiler.DecompilerSettings)

Example 27 with JCommander

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;
    }
}
Also used : JCommander(com.beust.jcommander.JCommander)

Example 28 with JCommander

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);
        }
    }
}
Also used : JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 29 with JCommander

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));
}
Also used : JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException)

Example 30 with JCommander

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;
}
Also used : JCommander(com.beust.jcommander.JCommander)

Aggregations

JCommander (com.beust.jcommander.JCommander)65 ParameterException (com.beust.jcommander.ParameterException)15 IOException (java.io.IOException)10 Map (java.util.Map)6 ParameterDescription (com.beust.jcommander.ParameterDescription)4 FileInputStream (java.io.FileInputStream)3 Console (com.beust.jcommander.internal.Console)2 DefaultCommand (com.evolveum.midpoint.cli.common.DefaultCommand)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Charsets (com.google.common.base.Charsets)2 Throwables (com.google.common.base.Throwables)2 HostAndPort (com.google.common.net.HostAndPort)2 Service (com.google.common.util.concurrent.Service)2 CreationException (com.google.inject.CreationException)2 SystemException (com.torodb.core.exceptions.SystemException)2 BackendPasswordConfig (com.torodb.packaging.config.model.backend.BackendPasswordConfig)2 AbstractDerby (com.torodb.packaging.config.model.backend.derby.AbstractDerby)2 AbstractPostgres (com.torodb.packaging.config.model.backend.postgres.AbstractPostgres)2 AbstractReplication (com.torodb.packaging.config.model.protocol.mongo.AbstractReplication)2 MongoPasswordConfig (com.torodb.packaging.config.model.protocol.mongo.MongoPasswordConfig)2