-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version information (fixes #112)
- Loading branch information
Showing
4 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/fortify/cli/app/FortifyCLIVersionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.fortify.cli.app; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
import picocli.CommandLine.IVersionProvider; | ||
|
||
public class FortifyCLIVersionProvider implements IVersionProvider { | ||
private static final Properties buildProperties = loadProperties(); | ||
|
||
@Override | ||
public String[] getVersion() throws Exception { | ||
return new String[] {String.format("%s version %s, built on %s" | ||
, buildProperties.getProperty("projectName", "fcli") | ||
, buildProperties.getProperty("projectVersion", "unknown") | ||
, buildProperties.getProperty("buildDate", "unknown"))}; | ||
} | ||
|
||
private static final Properties loadProperties() { | ||
final Properties p = new Properties(); | ||
try (final InputStream stream = FortifyCLIVersionProvider.class.getResourceAsStream("fcli-build.properties")) { | ||
if ( stream!=null ) { p.load(stream); } | ||
} catch ( IOException ioe ) { | ||
System.err.println("Error reading fcli-build.properties from classpath"); | ||
} | ||
return p; | ||
} | ||
|
||
} |