Search in sources :

Example 41 with OptionException

use of joptsimple.OptionException in project bisq-core by bisq-network.

the class BisqExecutable method setupInitialOptionParser.

public static boolean setupInitialOptionParser(String[] args) throws IOException {
    // We don't want to do the full argument parsing here as that might easily change in update versions
    // So we only handle the absolute minimum which is APP_NAME, APP_DATA_DIR_KEY and USER_DATA_DIR
    OptionParser parser = new OptionParser();
    parser.allowsUnrecognizedOptions();
    parser.accepts(AppOptionKeys.USER_DATA_DIR_KEY, description("User data directory", DEFAULT_USER_DATA_DIR)).withRequiredArg();
    parser.accepts(AppOptionKeys.APP_NAME_KEY, description("Application name", DEFAULT_APP_NAME)).withRequiredArg();
    OptionSet options;
    try {
        options = parser.parse(args);
    } catch (OptionException ex) {
        System.out.println("error: " + ex.getMessage());
        System.out.println();
        parser.printHelpOn(System.out);
        System.exit(EXIT_FAILURE);
        return false;
    }
    BisqEnvironment bisqEnvironment = getBisqEnvironment(options);
    // need to call that before BisqAppMain().execute(args)
    BisqExecutable.initAppDir(bisqEnvironment.getProperty(AppOptionKeys.APP_DATA_DIR_KEY));
    return true;
}
Also used : OptionException(joptsimple.OptionException) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser)

Aggregations

OptionException (joptsimple.OptionException)41 OptionSet (joptsimple.OptionSet)32 OptionParser (joptsimple.OptionParser)26 File (java.io.File)7 IOException (java.io.IOException)7 List (java.util.List)5 PrintWriter (java.io.PrintWriter)4 StringWriter (java.io.StringWriter)4 ArrayList (java.util.ArrayList)4 BuiltinHelpFormatter (joptsimple.BuiltinHelpFormatter)4 OptionSpec (joptsimple.OptionSpec)4 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)3 ThreadFactory (java.util.concurrent.ThreadFactory)3 BisqEnvironment (io.bisq.core.app.BisqEnvironment)2 BitsquareEnvironment (io.bitsquare.app.BitsquareEnvironment)2 FileInputStream (java.io.FileInputStream)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Properties (java.util.Properties)2 Logger (org.slf4j.Logger)2