-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Ruby 3.0 support] Add pager support into Launcher #2542
[Ruby 3.0 support] Add pager support into Launcher #2542
Conversation
@eregon May I ask you for some help here? |
I don't think we should touch runLauncherAction(). We can know if But I think we don't even need to know that, RubyLauncher's So I think just adding the logic there to set the output and use a pager seems the best. I think highlighting is not so important, and it would likely require more effort than what it's worth for the help output by the launcher ( |
Yes, that was my very first attempt, but let me show the issue This is an original
so if I modify just RubyLauncher's I think we can achieve the same result via |
I see, overriding printDefaultHelp() seems a reasonable compromise. If we want more control, we could always handle |
Given we probably need to wait for the pager to be quit and so need some cleanup after the output has been written, detecting and handling BTW, we can modify the launcher superclasses if needed, but if we can avoid it it's simpler/faster. |
Yes, the wait for the process to quit is a problem with any
I will try to draft PoC with handling |
@eregon I've decided to go the baby steps and the first one is to get on the same page regarding that point
The problem here is that protected boolean runLauncherAction() {
boolean printDefaultHelp = help || ((helpExpert || helpInternal) && kindAndCategory.isEmpty() && !helpVM);
// ...
} runLauncherAction (Launcher.java) and I think we can take "some" control in our hands and set If you would say – let's keep it, I will proceed with the next step – a new print method which will keep the logic around output, TTY check, process cleanup, etc, so WDYT? |
@@ -435,6 +435,8 @@ private void processArgument() throws CommandLineException { | |||
} else if (rubyOpts && argument.equals("--help")) { | |||
disallowedInRubyOpts(argument); | |||
break FOR; | |||
} else if (argument.equals("--help")) { | |||
config.showHelp = ShowHelp.LONG; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should explicitly do this here:
// add --help in unknown arguments so that runLauncherAction() actually prints the help
config.getUnknownArguments().add(argument);
break FOR;
because the fallthrough is quite subtle and far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done it that way and changed, will return back good point 👍🏼
Yes, the current diff looks good. You're right, we cannot "eat" the |
@eregon I'm very sorry, but I've made a mistake, the code I wrote never handles the LONG because it never reached it. The problem is the flow from the AbstractLanguageLauncher.java In short it looks like that final void launch(List<String> args, Map<String, String> defaultOptions, boolean doNativeSetup) {
// ... skipped ...
parseUnrecognizedOptions(getLanguageId(), polyglotOptions, unrecognizedArgs); // <-- Here we parse options
if (runLauncherAction()) { // <-- Here we will exit if we place `--help` in unrecognized args
return;
}
// ... skipped ...
launch(builder); // <-- here our RubyLauncher.launch is called
} As the result, I can either completely skip unrecognized options by simply not adding I see 3 ideas about what we can do about it:
|
@eregon Happy new Year 🎄 After a short break, I revisit this topic and I think I would like to go with option 1. The reason for that is a misleading name of So I think overriding is the way to go. |
I think overriding So we'd leave |
I'm sorry for holding this task for a while in a draft state, I have some IRL events which took all my evening, but I hope it will be resolved soon and I can continue. If you feel blocked by this – just tell me 💛 |
@Strech It's fine, this is currently not blocking anything. |
1564948
to
169251c
Compare
Hello Sergey Fedorov, thanks for contributing a PR to our project! We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address oni -(dot)- strech -(at)- gmail -(dot)- com. You can sign it at that link. If you think you've already signed it, please comment below and we'll check. |
2c83410
to
8995588
Compare
@eregon Hola 👋🏼 After our discussion, I've removed obsolete code and added logic similar to MRI
I'm not sure about the quality of the Java code, so I would appreciate some feedback. P.S Not sure why, but CRuby 2.6 tests are failing and I'm not sure how to test my changes 🤔 |
af01f4c
to
2c64f43
Compare
That looks good, but on |
Oh, I've noticed that, but though that it was due to unfinished code. I'm going to add the check back and incorporate it into the run launcher action. |
d7eeb42
to
9a1edd4
Compare
9a1edd4
to
ce01bac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, all is good now, I pushed a few extra changes/cleanups.
2ea9312
to
39d5750
Compare
39d5750
to
5a1f468
Compare
After digging into the MRI implementation and Graal Launcher I have a set of questions and problems to ask.
MRI-features question
The MRI pager support comes with variates of sub-features. And it would be cool to understand which one I should port:
COLUMNS
environment variable and word wrappingHAVE_WORKING_FORK
-thing which I'm not sure how is used 🤔Implementation question
In Graal SDK for Launcher, all the tiny methods to display help combined inside the
runLauncherAction
method which also should returntrue
to terminate the build part. And this method seems the best place to inject newoutput
. The problem I face is that I can't determine does the--help
is actually called or it's a--version
.Unfortunately in the Graal launcher
help
variable is declared asprivate
and I can't use it. Is there a way to understand it or I'm doing it in the wrong place?And the main issue I see is that logic is spread across many methods and some of them are responsible for termination decisions 🤔
P.S Does the
autoFlash
a concern or it's totally fine for such small output as help?