Skip to content

Conversation

caarlos0
Copy link
Member

@caarlos0 caarlos0 commented Dec 10, 2024

I'm not sure about this, as it might be slow in big tables...

This will go through all rows, calculate their widths, and set it as the column width if none was provided with -w.

# Without this patch:
echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table
 a  b
 …  …
# With this patch:
echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table
 a                        b
 aaaaaaaaaaaaaaaaaaaaaaa  bbbbbbbbbbbbbbbb
# In both:
echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table -w 5,5
 a      b
 aaaa…  bbbb…

closes #285

I'm not sure about this, as it might be slow in big tables...

This will go through all rows, calculate their widths, and set it as the
column width if none was provided with `-w`.

```console
$ echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table
 a  b
 …  …

$ echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table
 a                        b
 aaaaaaaaaaaaaaaaaaaaaaa  bbbbbbbbbbbbbbbb

$ echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table -w 5,5
 a      b
 aaaa…  bbbb…

```

closes #285
Copy link
Member

@meowgorithm meowgorithm left a comment

Choose a reason for hiding this comment

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

Awesome.

@caarlos0 caarlos0 merged commit bf06fce into main Dec 11, 2024
14 checks passed
@caarlos0 caarlos0 deleted the table-width branch December 11, 2024 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Various gum table width bugs
2 participants