-
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. |
Hi @xmbhasin, sorry for the wait. This looks good! Let's do this (grouping successful and unsuccessful queries), and omit the header if there is only one query. As an optional bonus, or a later effort, we were thinking something like this:
with the header line in grey. You can (hopefully) use the Indented is also okay:
How does this sound? |
As discussed, I'll try to achieve the following example format:
|
6950fc1
to
d4f60a5
Compare
* uses a new, more compact 3-column table for names * fixes insufficient indentation of 3rd column in Unison.Util.Pretty.column3Header
d4f60a5
to
6072ffa
Compare
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:
Note that due to partial failure (some name queries are invalid or unknown/empty), the entire names command is considered a failure.
The output is coloured to show success/failure of each name query at a glance
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.Updates
Output
type inUnison.Codebase.Editor.Output
so that theListNames
andGlobalListnames
constructors take an additionalString
value that is the name query for printing headers.Updates function
listOfNames
inUnison.CommandLine.OutputMessage
to print a compact table of hashes, hash kinds, and names. Sorts the names column alphabetically and orders rows by the names column.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
When a single name is queried, the output of
names
still includes a heading for the raw name query:2
The Kind column shows whether the hash refers to a term or a type. Kind may be an overloaded word here, but I wasn't aware of a better word.
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. Cases exercising the sorting of the tabular output were also added. 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).During design discussion we wanted to put the Names column first, but because of an outstanding pretty printing bug we decided to defer this. See #5550.
Evolution
Originally, the output of names remained similar to the original format but with headers for the name queries. This was changed to provide a more compact table-oriented format after design discussion.
Additionally, new Output constructors were initially added (BatchedOutput and IndentedOutput) to enable adding such headers without touching the original Output constructor signatures. This was changed to reduce the complexity overhead from the new constructors.