-
Notifications
You must be signed in to change notification settings - Fork 90
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
GHCup set command error improvement #861
Conversation
That looks interesting. I may be able to do proper review during weekend. |
So, I think we might not need this. If you look at the current branch ghc-compile from this PR: #854 Then you will see the behavior is already a bit different:
This makes sense, because now we have proper cross support. So what happens here is that GHCTargetVersion { _tvTarget = Just "ghc", _tvVersion = 9.2.5 } Previously, it would throw away the What we want to do here now is to just give a better error description. The error that's thrown and that triggers this message is here: Lines 208 to 218 in 6623e4b
We throw it in several places, e.g.: ghcup-hs/lib/GHCup/Download.hs Lines 319 to 326 in 6623e4b
So we might just have to add more info to the That way we have pushed down this concern out of the parser. I quite like the optparse test suite though. I think this should be extended. |
On second thought... I think my proposal has two issues:
|
Maybe it isn't too bad:
|
b46537f on branch https://github.com/haskell/ghcup-hs/compare/ghc-compile Can still be pumped up a little, but might be fine. |
Not bad indeed, turns out that while I typed The only nit is |
I'll try to write some test for optparse on a new thread. But it seems hard to take coverage test since the parser and the functionality are tangled. |
Yeah... that's the downside with this approach. The error is deep in the callstack and we don't have explicit information anymore what command triggered it. The only way I can see to fix that is to pass the Command (e.g. InstallCommand) down into the |
I'm in favor of the current solution. |
Some more tweaking leaves us with this:
I think it's quite useful to see what platform GHCup came up with when resolving the downloads. |
Meaningful improvement! Think from scratch, the error message And furthermore, the user may think if |
That's what the new error message basically says:
|
Well, I'm looking at Lines 709 to 712 in d143dae
Lines 156 to 165 in d143dae
|
I'm not sure I understand what you mean by candidates. |
This is a demo for #180.
The pr has no effect for command like
ghcup set ghc xxx
,ghcup set cabal xxx
.For old-style commands likes
ghcup set xxx
, it has two results. One can set ghc properly, likeghcup set latest
andghcup set recommended
, and others are not, likesghcup set ghc-9.2
, it outputs looks like the following even if I've ghc-9.2.8 installed.So my solution is:
For scenario one, gives a warning and continue the
set
operation since they might be valid and otherwise gives an error and stop the follow-up steps.For compatibility considerations, the
optparse
section is extracted to test every potential command that has the same effect during this pr.Now it looks like:
BEFORE:
AFTER:
BEFORE:
AFTER:
BEFORE:
AFTER:
BEFORE:
AFTER:
@hasufell I'm not sure if it is worth it just for a more readable prompt. It's more appreciable if you could take a look at this before I continue improvement so I can cut losses early maybe:)