001package co.codewizards.cloudstore.client; 002 003import java.io.IOException; 004import java.io.InputStream; 005import java.util.Properties; 006 007public class VersionSubCommand extends SubCommand { 008 009 public static String getVersion() throws IOException 010 { 011 Properties properties = new Properties(); 012 String resourceName = "/META-INF/maven/co.codewizards.cloudstore/co.codewizards.cloudstore.client/pom.properties"; 013 InputStream in = VersionSubCommand.class.getResourceAsStream(resourceName); 014 if (in == null) 015 return "UNKNOWN"; 016 017 try { 018 properties.load(in); 019 } catch (IOException x) { 020 throw new IOException("Cannot read resource: " + resourceName, x); 021 } finally { 022 in.close(); 023 } 024 String version = properties.getProperty("version"); 025 return version; 026 } 027 028 @Override 029 public String getSubCommandDescription() { 030 return "Display the version of this JAR."; 031 } 032 033 @Override 034 public void run() throws Exception 035 { 036 System.out.println(getVersion()); 037 } 038 039}