public CommandLine getCommandLine ( Options commandLineOptions ) throws Exception { final List < String > args = new ArrayList <> ( ) ; properties . asMap ( ) . forEach ( ( k , v ) -> { // only add supported options if ( commandLineOptions . hasOption ( k ) ) { final Option o = commandLineOptions . getOption ( k ) ; final String argument = "--" + o . getLongOpt ( ) ; // options without args if ( ! o . hasArg ( ) ) { final Boolean flag = Boolean . parseBoolean ( v ) ; // add key only if ( flag ) { args . add ( argument ) ; } } // add key and value else if ( ! o . hasArgs ( ) ) { args . add ( argument ) ; args . add ( v ) ; } // options with multiple args are not supported yet else { throw new IllegalArgumentException ( "Option '" + o + "' is not supported yet." ) ; } } } ) ; return CliFrontendParser . parse ( commandLineOptions , args . toArray ( new String [ args . size ( ) ] ) , true ) ; }
Parses the given command line options from the deployment properties . Ignores properties that are not defined by options .