@ VisibleForTesting public static void runMain ( final String [ ] args ) throws Exception { final CliHelpDefinition helpCli = new CliHelpDefinition ( ) ; try { Args . parse ( helpCli , args ) ; if ( helpCli . help ) { printUsage ( 0 ) ; return ; } } catch ( IllegalArgumentException invalidOption ) { // Ignore because it is probably one of the non-help options. } final CliDefinition cli = new CliDefinition ( ) ; try { List < String > unusedArguments = Args . parse ( cli , args ) ; if ( ! unusedArguments . isEmpty ( ) ) { System . out . println ( "\n\nThe following arguments are not recognized: " + unusedArguments ) ; printUsage ( 1 ) ; return ; } } catch ( IllegalArgumentException invalidOption ) { System . out . println ( "\n\n" + invalidOption . getMessage ( ) ) ; printUsage ( 1 ) ; return ; } configureLogs ( cli . verbose ) ; AbstractXmlApplicationContext context = new ClassPathXmlApplicationContext ( DEFAULT_SPRING_CONTEXT ) ; if ( cli . springConfig != null ) { context = new ClassPathXmlApplicationContext ( DEFAULT_SPRING_CONTEXT , cli . springConfig ) ; } try { context . getBean ( Main . class ) . run ( cli ) ; } finally { context . close ( ) ; } }
Runs the print .