Package liquibase.command

Examples of liquibase.command.LiquibaseCommand


            if (main.command.equals("help")) {
                main.printHelp();
                return;
            }

            LiquibaseCommand command;
            CommandLineParser commandParser = new GnuParser();
            if (main.command.equals("vagrant")) {
                command = new VagrantCommand(main);
                try {
                    CommandLine commandArguments = commandParser.parse(((VagrantCommand) command).getOptions(), main.commandArgs.toArray(new String[main.commandArgs.size()]));
                    ((VagrantCommand) command).setup(commandArguments);
                } catch (ParseException e) {
                    throw new UserError("Error parsing command arguments: "+e.getMessage());
                }
            } else if (main.command.equals("watch")) {
                ((StdErrLog) org.eclipse.jetty.util.log.Log.getRootLogger()).setLevel(StdErrLog.LEVEL_WARN);
                LogFactory.getInstance().setDefaultLoggingLevel(LogLevel.WARNING);
                command = new WatchCommand(main);

                Options options = new Options();
                options.addOption(OptionBuilder.hasArg().withDescription("Webserver port. Default 8080").create("port"));
                options.addOption(OptionBuilder.hasArg().withDescription("Database URL").isRequired().create("url"));
                options.addOption(OptionBuilder.hasArg().withDescription("Database username").isRequired().create("username"));
                options.addOption(OptionBuilder.hasArg().withDescription("Database password").isRequired().create("password"));

                CommandLine commandArguments = commandParser.parse(options, main.commandArgs.toArray(new String[main.commandArgs.size()]));
                ((WatchCommand) command).setUrl(commandArguments.getOptionValue("url"));
                ((WatchCommand) command).setUsername(commandArguments.getOptionValue("username"));
                ((WatchCommand) command).setPassword(commandArguments.getOptionValue("password"));
                if (commandArguments.hasOption("port")) {
                    ((WatchCommand) command).setPort(Integer.valueOf(commandArguments.getOptionValue("port")));
                }
            } else if (main.command.equals("convert")) {
                command = new ConvertCommand(main);

                Options options = new Options();
                options.addOption(OptionBuilder.hasArg().withDescription("Original changelog").isRequired().create("src"));
                options.addOption(OptionBuilder.hasArg().withDescription("Output changelog").isRequired().create("out"));
                options.addOption(OptionBuilder.hasArg().withDescription("Classpath").create("classpath"));

                CommandLine commandArguments = commandParser.parse(options, main.commandArgs.toArray(new String[main.commandArgs.size()]));
                ((ConvertCommand) command).setSrc(commandArguments.getOptionValue("src"));
                ((ConvertCommand) command).setOut(commandArguments.getOptionValue("out"));
                ((ConvertCommand) command).setClasspath(commandArguments.getOptionValue("classpath"));
            } else {
                throw new UserError("Unknown command: "+main.command);
            }

            command.execute();

            main.divider();
            main.out("Command executed successfully");

View Full Code Here

TOP

Related Classes of liquibase.command.LiquibaseCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.