@Test public void withValidConfigAndJdbcOverides() throws Exception { Path configFile = createAndPopulatePaths(getClass().getResource("/sample-config.json")); CliResult result = cliDelegate.execute( "-configfile", configFile.toString(), "-jdbc.autoCreateTables", "true", "-jdbc.url", "someurl"); assertThat(result).isNotNull(); assertThat(result.getConfig()).isPresent(); assertThat(result.getConfig()).isPresent(); assertThat(result.getStatus()).isEqualTo(0); assertThat(result.isSuppressStartup()).isFalse(); Config config = result.getConfig().get(); assertThat(config.getJdbcConfig()).isNotNull(); assertThat(config.getJdbcConfig().isAutoCreateTables()).isTrue(); assertThat(config.getJdbcConfig().getUrl()).isEqualTo("someurl"); }
public CliResult execute(String... args) throws Exception { LOGGER.debug("Execute with args [{}]", String.join(",", args)); final CommandLine commandLine = new CommandLine(TesseraCommand.class); final CLIExceptionCapturer mapper = new CLIExceptionCapturer(); commandLine.addSubcommand(new CommandLine(CommandLine.HelpCommand.class)); commandLine.addSubcommand(new CommandLine(KeyGenCommand.class, new KeyGenCommandFactory())); commandLine.addSubcommand(new CommandLine(KeyUpdateCommand.class, new KeyUpdateCommandFactory())); commandLine .registerConverter(Config.class, new ConfigConverter()) .registerConverter(ArgonOptions.class, new ArgonOptionsConverter()) .setSeparator(" ") .setCaseInsensitiveEnumValuesAllowed(true) .setExecutionExceptionHandler(mapper) .setParameterExceptionHandler(mapper) .setStopAtUnmatched(false); final CommandLine.ParseResult parseResult; try { parseResult = commandLine.parseArgs(args); } catch (CommandLine.ParameterException ex) { try { commandLine.getParameterExceptionHandler().handleParseException(ex, args); throw new CliException(ex.getMessage()); } catch (Exception e) { throw new CliException(ex.getMessage()); } } if (CommandLine.printHelpIfRequested(parseResult)) { return new CliResult(0, true, null); } if (!parseResult.hasSubcommand()) { final Config config; try { config = getConfigFromCLI(parseResult); } catch (NoTesseraCmdArgsException e) { commandLine.execute("help"); return new CliResult(0, true, null); } catch (NoTesseraConfigfileOptionException e) { throw new CliException("Missing required option '--configfile <config>'"); } LOGGER.debug("Executed with args [{}]", String.join(",", args)); LOGGER.trace("Config {}", JaxbUtil.marshalToString(config)); return new CliResult(0, false, config); } if (args.length == 1) { final CommandLine.ParseResult subcommand = parseResult.subcommand(); subcommand.asCommandLineList().get(0).execute("help"); return new CliResult(0, true, null); } commandLine.execute(args); if (mapper.getThrown() != null) { throw mapper.getThrown(); } return new CliResult(0, true, null); }
PicoCliDelegate { public CliResult execute(String... args) throws Exception { LOGGER.debug("Execute with args [{}]", String.join(",", args)); final CommandLine commandLine = new CommandLine(TesseraCommand.class); final CLIExceptionCapturer mapper = new CLIExceptionCapturer(); commandLine.addSubcommand(new CommandLine(CommandLine.HelpCommand.class)); commandLine.addSubcommand(new CommandLine(KeyGenCommand.class, new KeyGenCommandFactory())); commandLine.addSubcommand(new CommandLine(KeyUpdateCommand.class, new KeyUpdateCommandFactory())); commandLine .registerConverter(Config.class, new ConfigConverter()) .registerConverter(ArgonOptions.class, new ArgonOptionsConverter()) .setSeparator(" ") .setCaseInsensitiveEnumValuesAllowed(true) .setExecutionExceptionHandler(mapper) .setParameterExceptionHandler(mapper) .setStopAtUnmatched(false); final CommandLine.ParseResult parseResult; try { parseResult = commandLine.parseArgs(args); } catch (CommandLine.ParameterException ex) { try { commandLine.getParameterExceptionHandler().handleParseException(ex, args); throw new CliException(ex.getMessage()); } catch (Exception e) { throw new CliException(ex.getMessage()); } } if (CommandLine.printHelpIfRequested(parseResult)) { return new CliResult(0, true, null); } if (!parseResult.hasSubcommand()) { final Config config; try { config = getConfigFromCLI(parseResult); } catch (NoTesseraCmdArgsException e) { commandLine.execute("help"); return new CliResult(0, true, null); } catch (NoTesseraConfigfileOptionException e) { throw new CliException("Missing required option '--configfile <config>'"); } LOGGER.debug("Executed with args [{}]", String.join(",", args)); LOGGER.trace("Config {}", JaxbUtil.marshalToString(config)); return new CliResult(0, false, config); } if (args.length == 1) { final CommandLine.ParseResult subcommand = parseResult.subcommand(); subcommand.asCommandLineList().get(0).execute("help"); return new CliResult(0, true, null); } commandLine.execute(args); if (mapper.getThrown() != null) { throw mapper.getThrown(); } return new CliResult(0, true, null); } }
PicoCliDelegate { public CliResult execute(String... args) throws Exception { LOGGER.debug("Execute with args [{}]", String.join(",", args)); final CommandLine commandLine = new CommandLine(TesseraCommand.class); final CLIExceptionCapturer mapper = new CLIExceptionCapturer(); commandLine.addSubcommand(new CommandLine(CommandLine.HelpCommand.class)); commandLine.addSubcommand(new CommandLine(KeyGenCommand.class, new KeyGenCommandFactory())); commandLine.addSubcommand(new CommandLine(KeyUpdateCommand.class, new KeyUpdateCommandFactory())); commandLine .registerConverter(Config.class, new ConfigConverter()) .registerConverter(ArgonOptions.class, new ArgonOptionsConverter()) .setSeparator(" ") .setCaseInsensitiveEnumValuesAllowed(true) .setExecutionExceptionHandler(mapper) .setParameterExceptionHandler(mapper) .setStopAtUnmatched(false); final CommandLine.ParseResult parseResult; try { parseResult = commandLine.parseArgs(args); } catch (CommandLine.ParameterException ex) { try { commandLine.getParameterExceptionHandler().handleParseException(ex, args); throw new CliException(ex.getMessage()); } catch (Exception e) { throw new CliException(ex.getMessage()); } } if (CommandLine.printHelpIfRequested(parseResult)) { return new CliResult(0, true, null); } if (!parseResult.hasSubcommand()) { final Config config; try { config = getConfigFromCLI(parseResult); } catch (NoTesseraCmdArgsException e) { commandLine.execute("help"); return new CliResult(0, true, null); } catch (NoTesseraConfigfileOptionException e) { throw new CliException("Missing required option '--configfile <config>'"); } LOGGER.debug("Executed with args [{}]", String.join(",", args)); LOGGER.trace("Config {}", JaxbUtil.marshalToString(config)); return new CliResult(0, false, config); } if (args.length == 1) { final CommandLine.ParseResult subcommand = parseResult.subcommand(); subcommand.asCommandLineList().get(0).execute("help"); return new CliResult(0, true, null); } commandLine.execute(args); if (mapper.getThrown() != null) { throw mapper.getThrown(); } return new CliResult(0, true, null); } PicoCliDelegate(); private  PicoCliDelegate(final KeyPasswordResolver keyPasswordResolver); }
PicoCliDelegate { public CliResult execute(String... args) throws Exception { LOGGER.debug("Execute with args [{}]", String.join(",", args)); final CommandLine commandLine = new CommandLine(TesseraCommand.class); final CLIExceptionCapturer mapper = new CLIExceptionCapturer(); commandLine.addSubcommand(new CommandLine(CommandLine.HelpCommand.class)); commandLine.addSubcommand(new CommandLine(KeyGenCommand.class, new KeyGenCommandFactory())); commandLine.addSubcommand(new CommandLine(KeyUpdateCommand.class, new KeyUpdateCommandFactory())); commandLine .registerConverter(Config.class, new ConfigConverter()) .registerConverter(ArgonOptions.class, new ArgonOptionsConverter()) .setSeparator(" ") .setCaseInsensitiveEnumValuesAllowed(true) .setExecutionExceptionHandler(mapper) .setParameterExceptionHandler(mapper) .setStopAtUnmatched(false); final CommandLine.ParseResult parseResult; try { parseResult = commandLine.parseArgs(args); } catch (CommandLine.ParameterException ex) { try { commandLine.getParameterExceptionHandler().handleParseException(ex, args); throw new CliException(ex.getMessage()); } catch (Exception e) { throw new CliException(ex.getMessage()); } } if (CommandLine.printHelpIfRequested(parseResult)) { return new CliResult(0, true, null); } if (!parseResult.hasSubcommand()) { final Config config; try { config = getConfigFromCLI(parseResult); } catch (NoTesseraCmdArgsException e) { commandLine.execute("help"); return new CliResult(0, true, null); } catch (NoTesseraConfigfileOptionException e) { throw new CliException("Missing required option '--configfile <config>'"); } LOGGER.debug("Executed with args [{}]", String.join(",", args)); LOGGER.trace("Config {}", JaxbUtil.marshalToString(config)); return new CliResult(0, false, config); } if (args.length == 1) { final CommandLine.ParseResult subcommand = parseResult.subcommand(); subcommand.asCommandLineList().get(0).execute("help"); return new CliResult(0, true, null); } commandLine.execute(args); if (mapper.getThrown() != null) { throw mapper.getThrown(); } return new CliResult(0, true, null); } PicoCliDelegate(); private  PicoCliDelegate(final KeyPasswordResolver keyPasswordResolver); CliResult execute(String... args); }
PicoCliDelegate { public CliResult execute(String... args) throws Exception { LOGGER.debug("Execute with args [{}]", String.join(",", args)); final CommandLine commandLine = new CommandLine(TesseraCommand.class); final CLIExceptionCapturer mapper = new CLIExceptionCapturer(); commandLine.addSubcommand(new CommandLine(CommandLine.HelpCommand.class)); commandLine.addSubcommand(new CommandLine(KeyGenCommand.class, new KeyGenCommandFactory())); commandLine.addSubcommand(new CommandLine(KeyUpdateCommand.class, new KeyUpdateCommandFactory())); commandLine .registerConverter(Config.class, new ConfigConverter()) .registerConverter(ArgonOptions.class, new ArgonOptionsConverter()) .setSeparator(" ") .setCaseInsensitiveEnumValuesAllowed(true) .setExecutionExceptionHandler(mapper) .setParameterExceptionHandler(mapper) .setStopAtUnmatched(false); final CommandLine.ParseResult parseResult; try { parseResult = commandLine.parseArgs(args); } catch (CommandLine.ParameterException ex) { try { commandLine.getParameterExceptionHandler().handleParseException(ex, args); throw new CliException(ex.getMessage()); } catch (Exception e) { throw new CliException(ex.getMessage()); } } if (CommandLine.printHelpIfRequested(parseResult)) { return new CliResult(0, true, null); } if (!parseResult.hasSubcommand()) { final Config config; try { config = getConfigFromCLI(parseResult); } catch (NoTesseraCmdArgsException e) { commandLine.execute("help"); return new CliResult(0, true, null); } catch (NoTesseraConfigfileOptionException e) { throw new CliException("Missing required option '--configfile <config>'"); } LOGGER.debug("Executed with args [{}]", String.join(",", args)); LOGGER.trace("Config {}", JaxbUtil.marshalToString(config)); return new CliResult(0, false, config); } if (args.length == 1) { final CommandLine.ParseResult subcommand = parseResult.subcommand(); subcommand.asCommandLineList().get(0).execute("help"); return new CliResult(0, true, null); } commandLine.execute(args); if (mapper.getThrown() != null) { throw mapper.getThrown(); } return new CliResult(0, true, null); } PicoCliDelegate(); private  PicoCliDelegate(final KeyPasswordResolver keyPasswordResolver); CliResult execute(String... args);  }