Skip to content

Commit

Permalink
Add check that --help was used
Browse files Browse the repository at this point in the history
  • Loading branch information
Strech committed May 23, 2022
1 parent ecfbc76 commit 9a1edd4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/launcher/java/org/truffleruby/launcher/RubyLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class RubyLauncher extends AbstractLanguageLauncher {

private CommandLineOptions config;
private String implementationName = null;
private boolean helpOptionUsed;

public static void main(String[] args) {
new RubyLauncher().launch(args);
Expand Down Expand Up @@ -175,9 +176,19 @@ protected AbortException abortUnrecognizedArgument(String argument) {
"truffleruby: invalid option " + argument + " (Use --help for usage instructions.)");
}

@Override
protected boolean parseCommonOption(String defaultOptionPrefix, Map<String, String> polyglotOptions,
boolean experimentalOptions, String arg) {
if (arg.startsWith("--help")) {
helpOptionUsed = true;
}

return super.parseCommonOption(defaultOptionPrefix, polyglotOptions, experimentalOptions, arg);
}

@Override
protected boolean runLauncherAction() {
if (System.console() == null) {
if (!helpOptionUsed || System.console() == null) {
return super.runLauncherAction();
}

Expand Down

0 comments on commit 9a1edd4

Please sign in to comment.