Skip to content

Commit

Permalink
Merge pull request #674 from overturetool/pvj/version-arg-issue-673
Browse files Browse the repository at this point in the history
Add "-version" argument to the Overture command-line interface
  • Loading branch information
peterwvj authored Mar 14, 2018
2 parents 1a71f31 + 4d3e167 commit 6a4296f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions core/interpreter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,14 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.prop</include>
</includes>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.overture.interpreter;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Iterator;
Expand Down Expand Up @@ -93,7 +95,13 @@ public static void main(String[] args)

Properties.init(); // Read properties file, if any
Settings.usingCmdLine = true;


if(largs.contains("-version"))
{
println(getOvertureVersion());
System.exit(0);
}

for (Iterator<String> i = largs.iterator(); i.hasNext();)
{
String arg = i.next();
Expand Down Expand Up @@ -418,6 +426,20 @@ public void run()

System.exit(status == ExitStatus.EXIT_OK ? 0 : 1);
}

public static String getOvertureVersion() {
String path = "/version.prop";
InputStream stream = VDMJ.class.getResourceAsStream(path);
if (stream == null) return "UNKNOWN";
java.util.Properties props = new java.util.Properties();
try {
props.load(stream);
stream.close();
return (String)props.get("version");
} catch (IOException e) {
return "UNKNOWN";
}
}

private static void usage(String msg)
{
Expand All @@ -444,6 +466,7 @@ private static void usage(String msg)
System.err.println("-measures: disable recursive measure checking");
System.err.println("-log: enable real-time event logging");
System.err.println("-remote <class>: enable remote control");
System.err.println("-version: print Overture version number");

System.exit(1);
}
Expand Down
1 change: 1 addition & 0 deletions core/interpreter/src/main/resources/version.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${project.version}

0 comments on commit 6a4296f

Please sign in to comment.