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
Improve error messages on un-resolvable fuzzy command invocations #4573
Conversation
@@ -33,7 +53,7 @@ Definition args | |||
|
|||
.> debug.fuzzy-options view _ | |||
|
|||
Select a definition: |
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.
Unfortunately generic articles are complicated in English (a
vs an
), but I think things read okay without it.
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 think it'll be good to improve this at some point to be consistent with the minimally-robotic UCM message style, but not going to delay the PR.
@@ -9,6 +9,15 @@ module Unison.CommandLine.FZFResolvers | |||
projectBranchOptionsWithinCurrentProject, | |||
fuzzySelectFromList, | |||
multiResolver, | |||
definitionResolver, |
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.
Now that we don't need custom arg descriptions in each resolver, we can just export the whole resolver type :)
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.
ormolu
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.
ormolu
@@ -358,7 +358,14 @@ run verbosity dir stanzas codebase runtime sbRuntime nRuntime config ucmVersion | |||
let getRoot = fmap Branch.head . atomically $ readTMVar rootVar | |||
liftIO (parseInput codebase getRoot curPath numberedArgs patternMap args) >>= \case | |||
-- invalid command is treated as a failure | |||
Left msg -> liftIO (dieWithMsg $ Pretty.toPlain terminalWidth msg) | |||
Left msg -> do |
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.
Previously a failure in argument parsing would crash the transcript even if inside a ucm:error
block, now it prints the error the output but proceeds if it was an expected error.
@@ -38,48 +47,44 @@ import Unison.Util.Relation qualified as Relation | |||
type OptionFetcher = Codebase IO Symbol Ann -> ProjectContext -> Branch0 IO -> IO [Text] | |||
|
|||
data FZFResolver = FZFResolver | |||
{ argDescription :: Text, |
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.
No longer need a description in the resolver since we have one on each arg.
Overview
For fuzzy finds with no options
Before
After
For fuzzy finds with no resolvers and a missing arg
Before:
After:
Without this patch some command invocations can behave unintuitively, e.g. running
move.term
without any args will fuzzy search for the first arg, but then will silently not run anything because there's no fzf resolver for thenew name
argument which is required.This changes it so we validate that we have resolvers for all required arguments before we actually invoke any of them.
It also will fail with a nice message if a fuzzy-finder is invoked but doesn't have any options to select from.
Implementation notes
ucm:error
Test coverage
Added a couple transcript cases