Skip to content

feat: accept optional column argument for grid command#18187

Merged
fdncred merged 5 commits into
nushell:mainfrom
Juhan280:griddle-column-param
May 13, 2026
Merged

feat: accept optional column argument for grid command#18187
fdncred merged 5 commits into
nushell:mainfrom
Juhan280:griddle-column-param

Conversation

@Juhan280
Copy link
Copy Markdown
Contributor

@Juhan280 Juhan280 commented May 12, 2026

Description

The grid command is hardcoded to always look for name column. This pr attempts to solve this issue by accepting an additional column parameter.

Also, grid command used to return nothing instead of string if the input was an empty list, it is now resolved.

User-facing changes (Release notes)

The grid command now accepts an optional column name to display the contents of that column in a grid. One should no longer rely on the old behavior which automatically displays the name column as it is deprecated. Moreover, passing in a record as the input is also deprecated.

# before
ls | grid
{ name: test } | grid

# after
ls | grid name
[{ name: test }] | grid name

Additional notes

N/A

@Juhan280 Juhan280 marked this pull request as ready for review May 12, 2026 17:47
@fdncred fdncred added notes:breaking-changes Noted in Breaking Changes section notes:ready Indicates Ready for Release notes labels May 12, 2026
or record, it determines what to put in the grid by looking for a
column named 'name'. This is subject to change in the future."
"The `grid` command creates a concise gridded layout for the input. It
prints every item of the list in a grid layout. However, for table,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prints every item of the list in a grid layout. However, for table,
prints every item of the list in a grid layout. However, for table or record input,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally left out record as column name doesn't work for it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not? didn't it work in the past?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the same reason grid doesn't accept any (string, int, bool, etc). It doesn't make sense for a scalar value to be put in a grid.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, technically, it is a breaking change because you're removing this functionality. it's just that it's probably not used. As long as a list of records and tables work, it's probably fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not removing any functionality in this pr. They are just being deprecated. But yes, when they will eventually be removed, it will be breaking.

@Juhan280
Copy link
Copy Markdown
Contributor Author

Btw, i don't think it should be notes:breaking-changes, it just deprecates old behavior and introduces new behavior.

Also [] | grid now returning empty string instead of nothing is a bug fix.

@fdncred fdncred added notes:deprecations Noted in "Deprecations" section and removed notes:breaking-changes Noted in Breaking Changes section labels May 13, 2026
@fdncred fdncred merged commit 44e5904 into nushell:main May 13, 2026
17 checks passed
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 13, 2026

Thanks

@github-actions github-actions Bot added this to the v0.113.0 milestone May 13, 2026
@Juhan280 Juhan280 deleted the griddle-column-param branch May 13, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:deprecations Noted in "Deprecations" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants