class LegacyCliAdapter implements CliAdapter, Callable<CliResult> {

    static CliResult writeToOutputFile(Config config, Path outputPath) throws IOException {
        SystemAdapter systemAdapter = SystemAdapter.INSTANCE;
        systemAdapter.out().printf("Saving config to %s", outputPath);
        systemAdapter.out().println();
        JaxbUtil.marshalWithNoValidation(config, systemAdapter.out());
        systemAdapter.out().println();

        try (OutputStream outputStream = Files.newOutputStream(outputPath)) {
            JaxbUtil.marshal(config, outputStream);
            systemAdapter.out().printf("Saved config to  %s", outputPath);
            systemAdapter.out().println();
            return new CliResult(0, false, config);
        } catch (ConstraintViolationException validationException) {
            validationException.getConstraintViolations().stream()
                    .map(cv -> "Warning: " + cv.getMessage() + " on property " + cv.getPropertyPath())
                    .forEach(systemAdapter.err()::println);

            Files.write(outputPath, JaxbUtil.marshalToStringNoValidation(config).getBytes());
            systemAdapter.out().printf("Saved config to  %s", outputPath);
            systemAdapter.out().println();
            return new CliResult(2, false, config);
        }
    }

    public  LegacyCliAdapter();

}