Skip to content
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

'from-ssv' skips empty elements and shifts the remaining columns to the left #1350

Closed
kvrhdn opened this issue Feb 6, 2020 · 6 comments
Closed
Labels
🐛 bug Something isn't working polish this problem makes nu feel unpolished Stale used for marking issues and prs as stale

Comments

@kvrhdn
Copy link
Contributor

kvrhdn commented Feb 6, 2020

Describe the bug
If a space-separated table has an empty element (i.e. there is a row that has no value for some column), from-ssv will not detect this and shift all the next element to the left.

To Reproduce
Run some command that has space-separated table with an empty element.

In the following example the PORTS column is empty for the first element. Because of this, the value of the next column (NAMES) is shifted to the left and from-ssv splits the data into 2 tables.

❯ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
a41566c3765f        docsrs_web          "/opt/docsrs/entrypo…"   2 minutes ago       Up 2 minutes                            docsrs_web_run_1ab629ca8b57
c009496a92d6        postgres:alpine     "docker-entrypoint.s…"   3 minutes ago       Up 3 minutes        5432/tcp            docsrs_db_1

❯ docker ps | from-ssv
───┬──────────────┬────────────┬────────────────────────┬───────────────┬──────────────┬─────────────────────────────
 # │ CONTAINER ID │ IMAGE      │ COMMAND                │ CREATED       │ STATUS       │ PORTS 
───┼──────────────┼────────────┼────────────────────────┼───────────────┼──────────────┼─────────────────────────────
 0 │ a41566c3765f │ docsrs_web │ "/opt/docsrs/entrypo…" │ 2 minutes ago │ Up 2 minutes │ docsrs_web_run_1ab629ca8b57 
───┴──────────────┴────────────┴────────────────────────┴───────────────┴──────────────┴─────────────────────────────
───┬──────────────┬─────────────────┬────────────────────────┬───────────────┬──────────────┬──────────┬─────────────
 # │ CONTAINER ID │ IMAGE           │ COMMAND                │ CREATED       │ STATUS       │ PORTS    │ NAMES 
───┼──────────────┼─────────────────┼────────────────────────┼───────────────┼──────────────┼──────────┼─────────────
 1 │ c009496a92d6 │ postgres:alpine │ "docker-entrypoint.s…" │ 3 minutes ago │ Up 3 minutes │ 5432/tcp │ docsrs_db_1 
───┴──────────────┴─────────────────┴────────────────────────┴───────────────┴──────────────┴──────────┴─────────────

Expected behavior
I would expect from-ssv to detect if a column is empty and display the table correctly.

❯ docker ps | from-ssv
───┬──────────────┬─────────────────┬────────────────────────┬───────────────┬──────────────┬──────────┬────────────────────────────
 # │ CONTAINER ID │ IMAGE           │ COMMAND                │ CREATED       │ STATUS       │ PORTS    | NAMES
───┼──────────────┼─────────────────┼────────────────────────┼───────────────┼──────────────┼──────────┼────────────────────────────
 0 │ a41566c3765f │ docsrs_web      │ "/opt/docsrs/entrypo…" │ 2 minutes ago │ Up 2 minutes │          | docsrs_web_run_1ab629ca8b57 
 1 │ c009496a92d6 │ postgres:alpine │ "docker-entrypoint.s…" │ 3 minutes ago │ Up 3 minutes │ 5432/tcp │ docsrs_db_1 
───┴──────────────┴─────────────────┴────────────────────────┴───────────────┴──────────────┴──────────┴────────────────────────────

Screenshots
N/A

Configuration (please complete the following information):
Nu 0.9.0

@thegedge thegedge added 🐛 bug Something isn't working enhancement New feature or request polish this problem makes nu feel unpolished and removed enhancement New feature or request labels Feb 6, 2020
@thegedge
Copy link
Contributor

I think this is working as expected. If you use --aligned-columns you'll get the expected result. What do you think, @kvrhdn ?

@kvrhdn
Copy link
Contributor Author

kvrhdn commented Feb 16, 2020

Using --aligned-colums fixes this indeed! Note to myself: check the help page a bit more 😅

But it's not clear to me why this isn't the default behaviour? In which cases would you not want to parse using aligned columns?

@thegedge
Copy link
Contributor

But it's not clear to me why this isn't the default behaviour? In which cases would you not want to parse using aligned columns?

I'm not 100% sure why it wasn't chosen as the default, but my guess would be that there's a cost to aligned columns, so whoever created this command would like for the user to explicitly request that, or perhaps there are examples of commands that don't align the columns (I can't think of any right now), or maybe a bit of both.

Either way, we're really hoping to get aliases in soon, so if you wanted aligned columns to be the default, it should be easy to set up an alias that makes it do so 🎉 (I've done this for a lot of commands in my zsh profile)

@ilius
Copy link
Contributor

ilius commented Feb 7, 2021

I started defining functions in config.toml in startup section.
https://github.com/nushell/nushell/blob/main/docs/sample_config/config.toml

Once you get used to them, you will have much more power!

Aliases are very limited, for example you can't use pipe, unlike Bash.
But even in Bash, functions are recommended over aliases (except maybe for very simple cases).

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale used for marking issues and prs as stale label Jun 24, 2021
@github-actions
Copy link

github-actions bot commented Jul 7, 2021

This issue has been marked stale for more than 10 days without activity. Closing this issue, but if you find that the issue is still valid, please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working polish this problem makes nu feel unpolished Stale used for marking issues and prs as stale
Projects
None yet
Development

No branches or pull requests

3 participants