-
Notifications
You must be signed in to change notification settings - Fork 272
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
CLI names command can search for multiple names #5521
base: trunk
Are you sure you want to change the base?
Conversation
f36ebc3
to
6950fc1
Compare
Hi @xmbhasin this is great! Also, the thorough PR description is very helpful. I have some requests/suggestions: Instead of visually grouping the results with headings, which raises interesting/controversial decision 2, we can just put them back to back, i.e.:
or even without the extra blank line when grouping, I'm unsure one way or the other whether it would be helpful or unhelpful. (cc @hojberg ?). That way we can also avoid introducing the new Output constructors I believe the input constructor can then also go back to Also, once we merge this, I think we can go ahead and close #3557, since that's just about Let me know if I misunderstood something; I'm also happy to chat design here or on Discord whenever's good. |
@aryairani Thanks for taking a look. I agree with making a new ticket for The related change for I've got some draft changes that works as following for
Without the headings this might look like this:
I don't think the output with headings when just one arg is passed to Let me know if this helps convince. |
If we group successful and unsuccessful queries, we could print a header before each group instead, which should be relatively easy to do without introducing new Output constructors. Something like this:
With a single name query, we would have:
If there is only one query, it would be easy to omit the header with this approach. The type of the If we opt to have no headers at all then I think the regrouping/reordering would be a bit confusing. |
Overview
This change allows the
names
CLI command to take multiple name/hash arguments to be looked up in the codebase for matching terms.After this change, the output of names given multiple arguments looks like the following:
Closes #3557.
Implementation notes
In
Unison.Codebase.Editor.Input
, changesInput
constructorNamesI IsGlobal (HQ.HashQualified Name)
toNamesI IsGlobal [(RawQuery, ErrorMessageOrName)]
where the following type aliases are defined:This change is required so that a batch of names can be handled with the original raw query string available to be printed as headings in the final output and so error messages in parsing a raw query/arg can be printed if necessary for each query.
Updates
Unison.CommandLine.InputPatterns
to take multiple names and produce the modifiedNamesI
.Updates
Unison.Codebase.Editor.HandleInput
to handle the modifiedNamesI
by mapping over each name/hash query in the batch.Adds
BatchedOutput
andIndentedOutput
constructors toUnison.Codebase.Editor.Output
to help format the output ofnames
such that each raw name query becomes a header for each listing indented below it.Interesting/controversial decisions
Include anything that you thought twice about, debated, chose arbitrarily, etc.
What could have been done differently, but wasn't? And why?
1
I considered adding a
BatchedInput
constructor toUnison.Codebase.Editor.Input (Input)
, but it proved difficult to reach intoCli ()
monad produced by code that handles input to properly format a sequence of Inputs. The benefit of this approach may have been a more reusable/externalized approach to adding multiple argument handling to other input handlers.2
For simplicity and consistency, even when a single name is queried, the output of
names
now includes a heading for the raw name query:Test coverage
Existing transcript tests cover
names
anddebug.names.global
queries for single argument cases. Cases for handling multiple arguments were added to these tests. Existing transcript tests also cover the help output when using e.g.? names
.Loose ends
I want to cover adding multiple args support to
list
/ls
in a new issue (to be created).