private SchemaCrawlerCommandLine(
      final Config config2, final ConnectionOptions connectionOptions, final String... args)
      throws SchemaCrawlerException {
    if (args == null || args.length == 0) {
      throw new SchemaCrawlerException("No command line arguments provided");
    }

    String[] remainingArgs = args;

    final CommandParser commandParser = new CommandParser();
    remainingArgs = commandParser.parse(remainingArgs);
    if (!commandParser.hasOptions()) {
      throw new SchemaCrawlerException("No command specified");
    }
    command = commandParser.getOptions().toString();

    final OutputOptionsParser outputOptionsParser = new OutputOptionsParser();
    remainingArgs = outputOptionsParser.parse(remainingArgs);
    outputOptions = outputOptionsParser.getOptions();

    final boolean isBundledWithDriver = config2 != null;
    if (isBundledWithDriver) {
      this.config = config2;
    } else {
      this.config = new Config();
    }
    if (remainingArgs.length > 0) {
      final ConfigParser configParser = new ConfigParser();
      remainingArgs = configParser.parse(remainingArgs);
      config.putAll(configParser.getOptions());
    }

    if (connectionOptions != null) {
      this.connectionOptions = connectionOptions;
    } else if (isBundledWithDriver) {
      final BaseDatabaseConnectionOptionsParser bundledDriverConnectionOptionsParser =
          new BundledDriverConnectionOptionsParser(config);
      remainingArgs = bundledDriverConnectionOptionsParser.parse(remainingArgs);
      this.connectionOptions = bundledDriverConnectionOptionsParser.getOptions();
    } else {
      final CommandLineConnectionOptionsParser commandLineConnectionOptionsParser =
          new CommandLineConnectionOptionsParser(config);
      remainingArgs = commandLineConnectionOptionsParser.parse(remainingArgs);
      ConnectionOptions parsedConnectionOptions = commandLineConnectionOptionsParser.getOptions();
      if (parsedConnectionOptions == null) {
        final ConfigConnectionOptionsParser configConnectionOptionsParser =
            new ConfigConnectionOptionsParser(config);
        remainingArgs = configConnectionOptionsParser.parse(remainingArgs);
        parsedConnectionOptions = configConnectionOptionsParser.getOptions();
      }
      this.connectionOptions = parsedConnectionOptions;
    }

    final SchemaCrawlerOptionsParser schemaCrawlerOptionsParser =
        new SchemaCrawlerOptionsParser(config);
    remainingArgs = schemaCrawlerOptionsParser.parse(remainingArgs);
    schemaCrawlerOptions = schemaCrawlerOptionsParser.getOptions();

    if (remainingArgs.length > 0) {
      LOGGER.log(
          Level.INFO,
          "Too many command line arguments provided: " + ObjectToString.toString(remainingArgs));
    }
  }