Skip to content

Commit c3676a7

Browse files
committed
Use getOutput()/getError() from Launcher
1 parent ce01bac commit c3676a7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/launcher/java/org/truffleruby/launcher/RubyLauncher.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ protected void validateArguments(Map<String, String> polyglotOptions) {
5757

5858
@Override
5959
protected void printVersion() {
60-
System.out.println(TruffleRuby.getVersionString(getImplementationNameFromEngine()));
61-
System.out.println();
60+
getOutput().println(TruffleRuby.getVersionString(getImplementationNameFromEngine()));
61+
getOutput().println();
6262
printPolyglotVersions();
6363
}
6464

@@ -112,9 +112,9 @@ protected List<String> preprocessArguments(List<String> args, Map<String, String
112112
}
113113

114114
} catch (CommandLineException commandLineException) {
115-
System.err.println("truffleruby: " + commandLineException.getMessage());
115+
getError().println("truffleruby: " + commandLineException.getMessage());
116116
if (commandLineException.isUsageError()) {
117-
printHelp(System.err);
117+
printHelp(getError());
118118
}
119119
System.exit(1);
120120
}
@@ -228,7 +228,7 @@ private int runRubyMain(Context.Builder contextBuilder, CommandLineOptions confi
228228
case IRB:
229229
config.executionAction = ExecutionAction.PATH;
230230
if (System.console() != null) {
231-
System.err.println(
231+
getError().println(
232232
"[ruby] WARNING: truffleruby starts IRB when stdin is a TTY instead of reading from stdin, use '-' to read from stdin");
233233
config.executionAction = ExecutionAction.PATH;
234234
config.toExecute = "irb";
@@ -247,7 +247,7 @@ private int runRubyMain(Context.Builder contextBuilder, CommandLineOptions confi
247247
// Apply options to run gem/bundle more efficiently
248248
contextBuilder.option("engine.Mode", "latency");
249249
if (Boolean.getBoolean("truffleruby.launcher.log")) {
250-
System.err.println("[ruby] CONFIG: detected gem or bundle command, using --engine.Mode=latency");
250+
getError().println("[ruby] CONFIG: detected gem or bundle command, using --engine.Mode=latency");
251251
}
252252
}
253253

@@ -285,7 +285,7 @@ private int runContext(Context.Builder builder, CommandLineOptions config) {
285285
if (file.isString()) {
286286
config.toExecute = file.asString();
287287
} else {
288-
System.err
288+
getError()
289289
.println("truffleruby: No such file or directory -- " + config.toExecute + " (LoadError)");
290290
return 1;
291291
}
@@ -314,9 +314,9 @@ private int runContext(Context.Builder builder, CommandLineOptions config) {
314314
return exitCode;
315315
} catch (PolyglotException e) {
316316
if (e.isHostException()) { // GR-22071
317-
System.err.println("truffleruby: a host exception reached the top level:");
317+
getError().println("truffleruby: a host exception reached the top level:");
318318
} else {
319-
System.err.println(
319+
getError().println(
320320
"truffleruby: an exception escaped out of the interpreter - this is an implementation bug");
321321
}
322322
e.printStackTrace();
@@ -359,21 +359,21 @@ private static String getPagerFromEnv() {
359359

360360
private void printPreRunInformation(CommandLineOptions config) {
361361
if (config.showVersion) {
362-
System.out.println(TruffleRuby.getVersionString(getImplementationNameFromEngine()));
362+
getOutput().println(TruffleRuby.getVersionString(getImplementationNameFromEngine()));
363363
}
364364

365365
if (config.showCopyright) {
366-
System.out.println(TruffleRuby.RUBY_COPYRIGHT);
366+
getOutput().println(TruffleRuby.RUBY_COPYRIGHT);
367367
}
368368

369369
switch (config.showHelp) {
370370
case NONE:
371371
break;
372372
case SHORT:
373-
printShortHelp(System.out);
373+
printShortHelp(getOutput());
374374
break;
375375
case LONG:
376-
printHelp(System.out);
376+
printHelp(getOutput());
377377
break;
378378
}
379379
}

0 commit comments

Comments
 (0)