class Bootstrap {

    static ParseCommandLineArgsResult parseCommandLineArgs(String[] args) {
        final ServerOptions opts = new ServerOptions();
        final CommandLine cli = new CommandLine(opts);
        try {
            cli.parseArgs(args);

            if (cli.isUsageHelpRequested()) {
                cli.usage(cli.getOut());
                return new ParseCommandLineArgsResult(cli.getCommandSpec().exitCodeOnUsageHelp());
            } else if (cli.isVersionHelpRequested()) {
                cli.printVersionHelp(cli.getOut());
                return new ParseCommandLineArgsResult(cli.getCommandSpec().exitCodeOnVersionHelp());
            }
        } catch (ParameterException ex) {
            cli.getErr().println(ex.getMessage());
            if (!UnmatchedArgumentException.printSuggestions(ex, cli.getErr())) {
                ex.getCommandLine().usage(cli.getErr());
            }
            return new ParseCommandLineArgsResult(cli.getCommandSpec().exitCodeOnInvalidInput());
        } catch (Exception ex) {
            ex.printStackTrace(cli.getErr());
            return new ParseCommandLineArgsResult(cli.getCommandSpec().exitCodeOnExecutionException());
        }
        return new ParseCommandLineArgsResult(opts);
    }

}

class BootstrapTest {

    @Test
    public void testArgsInAbbreviationForm() {

        String[] args = new String[]{"-d", "-c", "path/to/config", "-p", "8080"};
        ParseCommandLineArgsResult ret = Bootstrap.parseCommandLineArgs(args);
        assertThat(ret.isExit()).isFalse();

        assertThat(ret.getExitCode()).isEqualTo(ExitCode.OK);
        ServerOptions options = ret.getOptions();
        assertThat(options).isNotNull();
        assertThat(options.docServiceEnabled()).isTrue();
        assertThat(options.port()).isEqualTo(8080);
        assertThat(options.configFilePath()).isEqualTo("path/to/config");
    }

}