Skip to content

Commit 96db661

Browse files
committed
[GR-11562] Rscript --version works.
PullRequest: fastr/1713
2 parents 02ad291 + bd43dff commit 96db661

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

com.oracle.truffle.r.launcher/src/com/oracle/truffle/r/launcher/RCmdOptions.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,6 @@ static void printHelp(Client client) {
389389
}
390390

391391
static void printVersion() {
392-
System.out.print("FastR version ");
393-
System.out.println(RVersionNumber.FULL);
394-
System.out.println(RVersionNumber.LICENSE);
392+
System.out.printf("R scripting front-end version %s%s\n", RVersionNumber.FULL, RVersionNumber.RELEASE_DATE);
395393
}
396394
}

com.oracle.truffle.r.launcher/src/com/oracle/truffle/r/launcher/RMain.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ protected void validateArguments(Map<String, String> polyglotOptions) {
160160
rArguments = preprocessRScriptOptions(options);
161161
} catch (PrintHelp e) {
162162
printHelp(OptionCategory.USER);
163+
} catch (PrintVersion e) {
164+
RCmdOptions.printVersion();
163165
}
164166
} else {
165167
rArguments = this.options.getArguments();
@@ -285,7 +287,11 @@ public static RuntimeException fatal(Throwable t, String message, Object... args
285287

286288
// CheckStyle: stop system..print check
287289

288-
private static String[] preprocessRScriptOptions(RCmdOptions options) throws PrintHelp {
290+
private static String[] preprocessRScriptOptions(RCmdOptions options) {
291+
if (options.getBoolean(RCmdOption.VERSION)) {
292+
throw new PrintVersion();
293+
}
294+
289295
String[] arguments = options.getArguments();
290296
int resultArgsLength = arguments.length;
291297
int firstNonOptionArgIndex = options.getFirstNonOptionArgIndex();
@@ -334,7 +340,15 @@ private static String[] preprocessRScriptOptions(RCmdOptions options) throws Pri
334340
}
335341

336342
@SuppressWarnings("serial")
337-
static class PrintHelp extends Exception {
343+
static class PrintHelp extends RuntimeException {
344+
@Override
345+
public synchronized Throwable fillInStackTrace() {
346+
return this;
347+
}
348+
}
349+
350+
@SuppressWarnings("serial")
351+
static class PrintVersion extends RuntimeException {
338352
@Override
339353
public synchronized Throwable fillInStackTrace() {
340354
return this;

0 commit comments

Comments
 (0)