public static int run(String[] args) throws Exception {
        return Scope.child(null, Collections.singletonMap(Scope.Attr.logService.name(), new CommandLineLoggerService()), new Scope.ScopedRunnerWithReturn<Integer>() {
            @Override
            public Integer run() throws Exception {
                Logger log = Scope.getCurrentScope().getLog(Main.class);
                boolean outputLoggingEnabled = false;

                try {
                    GlobalConfiguration globalConfiguration = LiquibaseConfiguration.getInstance().getConfiguration
                            (GlobalConfiguration.class);

                    if (!globalConfiguration.getShouldRun()) {
                        log.warning(LogType.USER_MESSAGE, (
                                String.format(coreBundle.getString("did.not.run.because.param.was.set.to.false"),
                                        LiquibaseConfiguration.getInstance().describeValueLookupLogic(
                                                globalConfiguration.getProperty(GlobalConfiguration.SHOULD_RUN)))));
                        return 0;
                    }


                    Main main = new Main();
                    log.info(LogType.USER_MESSAGE, CommandLineUtils.getBanner());

                    if ((args.length == 1) && ("--" + OPTIONS.HELP).equals(args[0])) {
                        main.printHelp(System.out);
                        return 0;
                    } else if ((args.length == 1) && ("--" + OPTIONS.VERSION).equals(args[0])) {
                        log.info(LogType.USER_MESSAGE,
                                String.format(coreBundle.getString("version.number"), LiquibaseUtil.getBuildVersion() +
                                        StreamUtil.getLineSeparator()));
                        return 0;
                    }

                    try {
                        main.parseOptions(args);
                    } catch (CommandLineParsingException e) {
                        log.warning(LogType.USER_MESSAGE, coreBundle.getString("how.to.display.help"));
                        throw e;
                    }

                    List<String> setupMessages = main.checkSetup();
                    if (!setupMessages.isEmpty()) {
                        main.printHelp(setupMessages, System.err);
                        return 1;
                    }

                    main.applyDefaults();
                    Scope.child(Scope.Attr.resourceAccessor, new ClassLoaderResourceAccessor(main.configureClassLoader()), () -> {
                        main.doMigration();

                        if (COMMANDS.UPDATE.equals(main.command)) {
                            log.info(LogType.USER_MESSAGE, coreBundle.getString("update.successful"));
                        } else if (main.command.startsWith(COMMANDS.ROLLBACK) && !main.command.endsWith("SQL")) {
                            log.info(LogType.USER_MESSAGE, coreBundle.getString("rollback.successful"));
                        } else if (!main.command.endsWith("SQL")) {
                            log.info(LogType.USER_MESSAGE, String.format(coreBundle.getString("command.successful"), main.command));
                        }

                    });
                } catch (Exception e) {
                    String message = e.getMessage();
                    if (e.getCause() != null) {
                        message = e.getCause().getMessage();
                    }
                    if (message == null) {
                        message = coreBundle.getString("unknown.reason");
                    }
                    // At a minimum, log the message.  We don't need to print the stack
                    // trace because the logger already did that upstream.
                    try {
                        if (e.getCause() instanceof ValidationFailedException) {
                            ((ValidationFailedException) e.getCause()).printDescriptiveError(System.out);
                        } else {
                            log.severe(LogType.USER_MESSAGE,
                                    (String.format(coreBundle.getString("unexpected.error"), message)), e);
                            log.severe(LogType.USER_MESSAGE, generateLogLevelWarningMessage(outputLoggingEnabled));
                        }
                    } catch (IllegalFormatException e1) {
                        e1.printStackTrace();
                    }
                    throw new LiquibaseException(String.format(coreBundle.getString("unexpected.error"), message), e);
                }
                return 0;
            }
        });


    }
public static int run(String[] args) throws Exception {
        return Scope.child(null, Collections.singletonMap(Scope.Attr.logService.name(), new CommandLineLoggerService()), new Scope.ScopedRunnerWithReturn<Integer>() {
            @Override
            public Integer run() throws Exception {
                Logger log = Scope.getCurrentScope().getLog(Main.class);
                boolean outputLoggingEnabled = false;

                try {
                    GlobalConfiguration globalConfiguration = LiquibaseConfiguration.getInstance().getConfiguration
                            (GlobalConfiguration.class);

                    if (!globalConfiguration.getShouldRun()) {
                        log.warning(LogType.USER_MESSAGE, (
                                String.format(coreBundle.getString("did.not.run.because.param.was.set.to.false"),
                                        LiquibaseConfiguration.getInstance().describeValueLookupLogic(
                                                globalConfiguration.getProperty(GlobalConfiguration.SHOULD_RUN)))));
                        return 0;
                    }


                    Main main = new Main();
                    log.info(LogType.USER_MESSAGE, CommandLineUtils.getBanner());

                    if ((args.length == 1) && ("--" + OPTIONS.HELP).equals(args[0])) {
                        main.printHelp(System.out);
                        return 0;
                    } else if ((args.length == 1) && ("--" + OPTIONS.VERSION).equals(args[0])) {
                        log.info(LogType.USER_MESSAGE,
                                String.format(coreBundle.getString("version.number"), LiquibaseUtil.getBuildVersion() +
                                        StreamUtil.getLineSeparator()));
                        return 0;
                    }

                    try {
                        main.parseOptions(args);
                    } catch (CommandLineParsingException e) {
                        log.warning(LogType.USER_MESSAGE, coreBundle.getString("how.to.display.help"));
                        throw e;
                    }

                    List<String> setupMessages = main.checkSetup();
                    if (!setupMessages.isEmpty()) {
                        main.printHelp(setupMessages, System.err);
                        return 1;
                    }

                    main.applyDefaults();
                    Scope.child(Scope.Attr.resourceAccessor, new ClassLoaderResourceAccessor(main.configureClassLoader()), () -> {
                        main.doMigration();

                        if (COMMANDS.UPDATE.equals(main.command)) {
                            log.info(LogType.USER_MESSAGE, coreBundle.getString("update.successful"));
                        } else if (main.command.startsWith(COMMANDS.ROLLBACK) && !main.command.endsWith("SQL")) {
                            log.info(LogType.USER_MESSAGE, coreBundle.getString("rollback.successful"));
                        } else if (!main.command.endsWith("SQL")) {
                            log.info(LogType.USER_MESSAGE, String.format(coreBundle.getString("command.successful"), main.command));
                        }

                    });
                } catch (Exception e) {
                    String message = e.getMessage();
                    if (e.getCause() != null) {
                        message = e.getCause().getMessage();
                    }
                    if (message == null) {
                        message = coreBundle.getString("unknown.reason");
                    }
                    
                    
                    try {
                        if (e.getCause() instanceof ValidationFailedException) {
                            ((ValidationFailedException) e.getCause()).printDescriptiveError(System.out);
                        } else {
                            log.severe(LogType.USER_MESSAGE,
                                    (String.format(coreBundle.getString("unexpected.error"), message)), e);
                            log.severe(LogType.USER_MESSAGE, generateLogLevelWarningMessage(outputLoggingEnabled));
                        }
                    } catch (IllegalFormatException e1) {
                        e1.printStackTrace();
                    }
                    throw new LiquibaseException(String.format(coreBundle.getString("unexpected.error"), message), e);
                }
                return 0;
            }
        });


    }
public static int run ( String [ ] args ) throws Exception { return Scope . child ( null , Collections . singletonMap ( Scope . Attr . logService . name ( ) , new CommandLineLoggerService ( ) ) , new Scope . ScopedRunnerWithReturn < Integer > ( ) { @ Override public Integer run ( ) throws Exception { Logger log = Scope . getCurrentScope ( ) . getLog ( Main . class ) ; boolean outputLoggingEnabled = false ; try { GlobalConfiguration globalConfiguration = LiquibaseConfiguration . getInstance ( ) . getConfiguration ( GlobalConfiguration . class ) ; if ( ! globalConfiguration . getShouldRun ( ) ) { log . warning ( LogType . USER_MESSAGE , ( String . format ( coreBundle . getString ( "did.not.run.because.param.was.set.to.false" ) , LiquibaseConfiguration . getInstance ( ) . describeValueLookupLogic ( globalConfiguration . getProperty ( GlobalConfiguration . SHOULD_RUN ) ) ) ) ) ; return 0 ; } Main main = new Main ( ) ; log . info ( LogType . USER_MESSAGE , CommandLineUtils . getBanner ( ) ) ; if ( ( args . length == 1 ) && ( "--" + OPTIONS . HELP ) . equals ( args [ 0 ] ) ) { main . printHelp ( System . out ) ; return 0 ; } else if ( ( args . length == 1 ) && ( "--" + OPTIONS . VERSION ) . equals ( args [ 0 ] ) ) { log . info ( LogType . USER_MESSAGE , String . format ( coreBundle . getString ( "version.number" ) , LiquibaseUtil . getBuildVersion ( ) + StreamUtil . getLineSeparator ( ) ) ) ; return 0 ; } try { main . parseOptions ( args ) ; } catch ( CommandLineParsingException e ) { log . warning ( LogType . USER_MESSAGE , coreBundle . getString ( "how.to.display.help" ) ) ; throw e ; } List < String > setupMessages = main . checkSetup ( ) ; if ( ! setupMessages . isEmpty ( ) ) { main . printHelp ( setupMessages , System . err ) ; return 1 ; } main . applyDefaults ( ) ; Scope . child ( Scope . Attr . resourceAccessor , new ClassLoaderResourceAccessor ( main . configureClassLoader ( ) ) , ( ) -> { main . doMigration ( ) ; if ( COMMANDS . UPDATE . equals ( main . command ) ) { log . info ( LogType . USER_MESSAGE , coreBundle . getString ( "update.successful" ) ) ; } else if ( main . command . startsWith ( COMMANDS . ROLLBACK ) && ! main . command . endsWith ( "SQL" ) ) { log . info ( LogType . USER_MESSAGE , coreBundle . getString ( "rollback.successful" ) ) ; } else if ( ! main . command . endsWith ( "SQL" ) ) { log . info ( LogType . USER_MESSAGE , String . format ( coreBundle . getString ( "command.successful" ) , main . command ) ) ; } } ) ; } catch ( Exception e ) { String message = e . getMessage ( ) ; if ( e . getCause ( ) != null ) { message = e . getCause ( ) . getMessage ( ) ; } if ( message == null ) { message = coreBundle . getString ( "unknown.reason" ) ; } // At a minimum, log the message.  We don't need to print the stack // trace because the logger already did that upstream. try { if ( e . getCause ( ) instanceof ValidationFailedException ) { ( ( ValidationFailedException ) e . getCause ( ) ) . printDescriptiveError ( System . out ) ; } else { log . severe ( LogType . USER_MESSAGE , ( String . format ( coreBundle . getString ( "unexpected.error" ) , message ) ) , e ) ; log . severe ( LogType . USER_MESSAGE , generateLogLevelWarningMessage ( outputLoggingEnabled ) ) ; } } catch ( IllegalFormatException e1 ) { e1 . printStackTrace ( ) ; } throw new LiquibaseException ( String . format ( coreBundle . getString ( "unexpected.error" ) , message ) , e ) ; } return 0 ; } } ) ; }
Process the command line arguments and perform the appropriate main action (update, rollback etc.)

@param args the command line arguments
@return the errorlevel to be returned to the operating system, e.g. for further processing by scripts
@throws LiquibaseException a runtime exception
Process the command line arguments and perform the appropriate main action ( update rollback etc . )