use of co.rsk.cli.CliArgs in project rskj by rsksmart.
the class MigrationTool method main.
public static void main(String[] commandLineArgs) throws IOException {
CliArgs.Parser<Migrator.MigratorOptions, Migrator.MigratorFlags> parser = new CliArgs.Parser<>(Migrator.MigratorOptions.class, Migrator.MigratorFlags.class);
CliArgs<Migrator.MigratorOptions, Migrator.MigratorFlags> cliArgs = parser.parse(commandLineArgs);
MigratorConfiguration configuration = new MigratorConfiguration(cliArgs.getOptions().get(Migrator.MigratorOptions.INPUT_FILE), cliArgs.getOptions().get(Migrator.MigratorOptions.MIGRATION_FILE), cliArgs.getOptions().get(Migrator.MigratorOptions.OUTPUT_FILE), cliArgs.getFlags().contains(Migrator.MigratorFlags.REPLACE_IN_PLACE));
Migrator migrator = new Migrator(configuration);
String migratedConfigOutput = migrator.migrateConfiguration();
Path destination = configuration.getDestinationConfiguration();
Files.write(destination, migratedConfigOutput.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
System.out.println("Configuration successfully migrated.");
System.out.printf("Source: %s\nDestination: %s\n", configuration.getSourceConfiguration(), destination);
}