Clean up Main class for readability

This commit is contained in:
chubtub 2024-01-23 13:36:01 -05:00
parent ea79dbfddf
commit 5e3ab59dad

View File

@ -31,17 +31,7 @@ public class Main {
String version = new String(content);
System.out.println("TCG rimtool version: " + version);
} catch (IOException e) {
System.out.println("Installation file VERSION not found.");
String filename = new File(Main.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).getName();
Pattern pattern = Pattern.compile("(?<=tcg_rim_tool-)[0-9]\\.[0-9]\\.[0-9]");
Matcher matcher = pattern.matcher(filename);
if (matcher.find()) {
System.out.println("TCG rimtool version: " + matcher.group());
}
parseVersionFromJar();
}
} else {
if (!commander.getVerifyFile().isEmpty()) {
@ -127,4 +117,21 @@ public class Main {
}
}
}
/**
* This method parses the version number from the jar filename in the absence of
* the VERSION file expected with an rpm installation.
*/
private static void parseVersionFromJar() {
System.out.println("Installation file VERSION not found.");
String filename = new File(Main.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).getName();
Pattern pattern = Pattern.compile("(?<=tcg_rim_tool-)[0-9]\\.[0-9]\\.[0-9]");
Matcher matcher = pattern.matcher(filename);
if (matcher.find()) {
System.out.println("TCG rimtool version: " + matcher.group());
}
}
}