@Test public void showVersionTest() throws Exception { CliOptions optionsWithVersion = new CliOptions() { @Override public InputStream getPropertiesInputStream(String path) { return toInputStream("project.version = testVersion\n", UTF_8); } }; CmdLineParser parserWithVersion = new CmdLineParser(optionsWithVersion); parserWithVersion.parseArgument("--version"); String output = tapSystemOutNormalized(optionsWithVersion::showVersion); assertThat(output).isEqualTo("testVersion\n"); parserWithVersion.parseArgument("-v"); String aliasOutput = tapSystemOutNormalized(optionsWithVersion::showVersion); assertThat(aliasOutput).isEqualTo("testVersion\n"); }
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public void showVersion() { try (InputStream propertyInputStream = getPropertiesInputStream("/.properties")) { if (propertyInputStream == null) { throw new VersionNotFoundException("No version information available"); } Properties properties = new Properties(); properties.load(propertyInputStream); System.out.println(properties.getProperty("project.version")); } catch (IOException e) { throw new VersionNotFoundException("No version information available", e); } }
CliOptions { @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public void showVersion() { try (InputStream propertyInputStream = getPropertiesInputStream("/.properties")) { if (propertyInputStream == null) { throw new VersionNotFoundException("No version information available"); } Properties properties = new Properties(); properties.load(propertyInputStream); System.out.println(properties.getProperty("project.version")); } catch (IOException e) { throw new VersionNotFoundException("No version information available", e); } } }
CliOptions { @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public void showVersion() { try (InputStream propertyInputStream = getPropertiesInputStream("/.properties")) { if (propertyInputStream == null) { throw new VersionNotFoundException("No version information available"); } Properties properties = new Properties(); properties.load(propertyInputStream); System.out.println(properties.getProperty("project.version")); } catch (IOException e) { throw new VersionNotFoundException("No version information available", e); } }  }
CliOptions { @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public void showVersion() { try (InputStream propertyInputStream = getPropertiesInputStream("/.properties")) { if (propertyInputStream == null) { throw new VersionNotFoundException("No version information available"); } Properties properties = new Properties(); properties.load(propertyInputStream); System.out.println(properties.getProperty("project.version")); } catch (IOException e) { throw new VersionNotFoundException("No version information available", e); } }  OutputFormat getOutputFormat(); boolean isShowAvailableUpdates(); boolean isVerbose(); String appendFilePathIfNotPresent(@NonNull String updateCenter); @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") void showVersion(); boolean isShowHelp(); boolean isUseLatestSpecified(); boolean isSkipFailedPlugins(); boolean isUseLatestAll(); InputStream getPropertiesInputStream(String path); boolean isShowVersion(); }
CliOptions { @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public void showVersion() { try (InputStream propertyInputStream = getPropertiesInputStream("/.properties")) { if (propertyInputStream == null) { throw new VersionNotFoundException("No version information available"); } Properties properties = new Properties(); properties.load(propertyInputStream); System.out.println(properties.getProperty("project.version")); } catch (IOException e) { throw new VersionNotFoundException("No version information available", e); } }  OutputFormat getOutputFormat(); boolean isShowAvailableUpdates(); boolean isVerbose(); String appendFilePathIfNotPresent(@NonNull String updateCenter); @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") void showVersion(); boolean isShowHelp(); boolean isUseLatestSpecified(); boolean isSkipFailedPlugins(); boolean isUseLatestAll(); InputStream getPropertiesInputStream(String path); boolean isShowVersion();  }