All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liquibase.command.core.GenerateChangelogCommandStep Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package liquibase.command.core;

import liquibase.command.*;
import liquibase.configuration.ConfigurationValueObfuscator;
import liquibase.exception.CommandExecutionException;

import java.util.Arrays;

public class GenerateChangelogCommandStep extends AbstractCliWrapperCommandStep {

    public static final String[] COMMAND_NAME = {"generateChangelog"};

    public static final CommandArgumentDefinition USERNAME_ARG;
    public static final CommandArgumentDefinition PASSWORD_ARG;
    public static final CommandArgumentDefinition URL_ARG;
    public static final CommandArgumentDefinition CHANGELOG_FILE_ARG;
    public static final CommandArgumentDefinition DATA_OUTPUT_DIRECTORY;
    public static final CommandArgumentDefinition EXCLUDE_OBJECTS_ARG;
    public static final CommandArgumentDefinition INCLUDE_OBJECTS_ARG;
    public static final CommandArgumentDefinition INCLUDE_SCHEMA_ARG;
    public static final CommandArgumentDefinition INCLUDE_CATALOG_ARG;
    public static final CommandArgumentDefinition INCLUDE_TABLESPACE_ARG;
    public static final CommandArgumentDefinition SCHEMAS_ARG;
    public static final CommandArgumentDefinition DIFF_TYPES_ARG;
    public static final CommandArgumentDefinition DRIVER_ARG;
    public static final CommandArgumentDefinition DRIVER_PROPERTIES_FILE_ARG;
    public static final CommandArgumentDefinition OVERWRITE_OUTPUT_FILE_ARG;

    static {
        CommandBuilder builder = new CommandBuilder(COMMAND_NAME);
        URL_ARG = builder.argument(CommonArgumentNames.URL, String.class).required()
                .description("The JDBC database connection URL").build();
        USERNAME_ARG = builder.argument(CommonArgumentNames.USERNAME, String.class)
                .description("Username to use to connect to the database").build();
        PASSWORD_ARG = builder.argument(CommonArgumentNames.PASSWORD, String.class)
                .description("Password to use to connect to the database")
                .setValueObfuscator(ConfigurationValueObfuscator.STANDARD)
                .build();
        DRIVER_ARG = builder.argument("driver", String.class)
                .description("The JDBC driver class").build();
        DRIVER_PROPERTIES_FILE_ARG = builder.argument("driverPropertiesFile", String.class)
                .description("The JDBC driver properties file").build();
        CHANGELOG_FILE_ARG = builder.argument(CommonArgumentNames.CHANGELOG_FILE, String.class).required()
                .description("File to write changelog to").build();
        DATA_OUTPUT_DIRECTORY = builder.argument("dataOutputDirectory", String.class)
                .description("Directory to write table data to").build();
        EXCLUDE_OBJECTS_ARG = builder.argument("excludeObjects", String.class)
                .description("Objects to exclude from diff").build();
        INCLUDE_OBJECTS_ARG = builder.argument("includeObjects", String.class)
                .description("Objects to include in diff").build();
        INCLUDE_TABLESPACE_ARG = builder.argument("includeTablespace", String.class)
                .description("Include the tablespace attribute in the changelog").build();
        SCHEMAS_ARG = builder.argument("schemas", String.class)
                .description("Schemas to include in diff").build();
        INCLUDE_SCHEMA_ARG = builder.argument("includeSchema", Boolean.class)
                .defaultValue(false)
                .description("If true, the schema will be included in generated changeSets").build();
        INCLUDE_CATALOG_ARG = builder.argument("includeCatalog", Boolean.class)
                .defaultValue(false)
                .description("If true, the catalog will be included in generated changeSets").build();
        DIFF_TYPES_ARG = builder.argument("diffTypes", String.class)
                .description("Types of objects to compare").build();
        OVERWRITE_OUTPUT_FILE_ARG = builder.argument("overwriteOutputFile", String.class)
                .description("Flag to allow overwriting of output changelog file").build();
    }


    @Override
    public String[][] defineCommandNames() {
        return new String[][] { COMMAND_NAME };
    }

    @Override
    protected String[] collectArguments(CommandScope commandScope) throws CommandExecutionException {
        return collectArguments(commandScope, Arrays.asList("dataOutputDirectory"), null);
    }

    @Override
    public void adjustCommandDefinition(CommandDefinition commandDefinition) {
        commandDefinition.setShortDescription("Generate a changelog");
        commandDefinition.setLongDescription("Writes Change Log XML to copy the current state of the database to standard out or a file");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy