Show ? for optional entries when displaying CellPaths#14042
Show ? for optional entries when displaying CellPaths#14042fdncred merged 2 commits intonushell:mainfrom aionescu:cellpath-display-optional
? for optional entries when displaying CellPaths#14042Conversation
|
Implementation note: I'm pretty annoyed by the duplicated Extracting the check into a function or macro also seems overkill for just 2 repetitions. If anyone has better suggestions, please let me know. |
|
Ok, I forgot to pass While this looks pretty weird, However, in (what I assume is) the very common case of |
Yeah, discovered this behavior of select generating new column names from the cell-path's when fixing a bug as well
Apart from that whole thing (mis?)using the
Thanks for fixing the optional cell-path part! |
|
@sholderbach does that mean we're ready to land this? |
|
I kind of think we should decouple @aionescu do you want to implement the rest of the improvements to the cell path display output as @IanManske and I discussed in #13362 and #14090 ? |
|
@sholderbach Yeah, they look easy enough (famous last words?). Should I add them all to this PR, or make a separate one? |
Whatever is practical to you, if you want to update the |
|
Thanks |
|
I think it's actually a breaking change: # Before this PR the following line works:
http get https://api.github.com/repos/nushell/nushell/releases/latest | select -i tag_name assets?.id? | flatten | rename -c {'assets.id': id}
# After this PR the above line will broken and should be changed to:
http get https://api.github.com/repos/nushell/nushell/releases/latest | select -i tag_name assets?.id? | flatten | rename -c {'assets?.id?': id}It's weird that after this change the column names will have a ? suffix if [[version name]; ['0.1.0' nushell] ['0.1.1' fish] ['0.2.0' zsh]] | select -i version name | columns
0 version?
1 name? |
|
Good catch. The column names should be required to have |
Description
This PR makes the
Displayimplementation forCellPathshow a?suffix on every optional entry, which makes the output consistent with the language syntax.Before this PR, the printing of cell paths was confusing, e.g.
$.xand$.x?were both printed asx. Now, the second one is printed asx?.User-Facing Changes
The formatting of cell paths now matches the syntax used to create them, reducing confusion.
Tests + Formatting
All tests pass, including
stdlibtests.After Submitting