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

Option to ignore line and print as is #4

Open
LukasWillin opened this issue Jul 19, 2022 · 9 comments
Open

Option to ignore line and print as is #4

LukasWillin opened this issue Jul 19, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@LukasWillin
Copy link
Contributor

LukasWillin commented Jul 19, 2022

Hey Luca

So I required a Solution to be able to print tables with same column widths but interspersed with user messages or titles because I am using the column command to build some of the CLI interfaces to display system status etc.

I already have a working implementation but I am not sure if you even want to support this in the scope of this project Because well... it's quite a niche use case I would assume.
So I would like to discuss it first and clarify the use case.

What it would achieve

Parameter

Function supports an additional parameter which accepts a prefix-string -i | --ignore-line-prefix.
Example: Given argument -i '\i' prefixed lines with \i will be ignored and not treated as columns and printed as is.

Per Line from stdin

  1. If $line starts with given argument from parameter -i do not use it to align columns and skip it.
  2. If $line starts with given argument from parameter -i print only the sub-string starting from ignore-line-prefix's length



A table could be something like the following where sections are separated by titles or messages but columns for all sections are aligned the same.

This is a title or message for section 1:
Statuslabel A1     : value-xyz A1   Statuslabel A2 : value A2       Statuslabel A3 : value A3
Statuslabel-xyz B1 : value B1       Statuslabel B2 : value B2       Statuslabel B3 : value-xyz B3

This is a title or message for section 2:
Statuslabel C1     : value C1       Statuslabel C2 : value-xyz C2   Statuslabel C3 : value C3
Statuslabel D1     : value-xyz D1   Statuslabel D2 : value D2       Statuslabel D3 : value D3

...

Let me know what you think and if I should open a PR for you to review.

Cheers :)
Lukas

@LukeSavefrogs LukeSavefrogs pinned this issue Jul 22, 2022
@LukeSavefrogs
Copy link
Owner

Hi Lukas... I'll try to look into this issue and understand what you need.

Thank you in advance for your contribution ☺

@LukeSavefrogs LukeSavefrogs added the enhancement New feature or request label Nov 2, 2022
@LukeSavefrogs
Copy link
Owner

LukeSavefrogs commented Nov 3, 2022

Hi @LukasWillin,
I would really like to see your working implementation, so that i can understand if could be a useful addition to the project..

Do you think you could update your fork and make a PR?

Sorry for the delay but i was caught up with a lot of things. 😃

@LukeSavefrogs
Copy link
Owner

Also, could you include a separate file in the tests/ folder which contains the desired output first with column and then with column_ansi? This way it's easier to understand the differences.

@LukasWillin
Copy link
Contributor Author

Hi Luca

Sry for the late response! I will do so this afternoon.

@LukeSavefrogs
Copy link
Owner

Hi Luca

Sry for the late response! I will do so this afternoon.

Ty! 😄

@LukasWillin
Copy link
Contributor Author

@LukeSavefrogs
I created a draft PR, as I didn't have time today to test how my changes play together with yours just yet.
So currently the code changes are just there for you to review if you want.
Automated tests should hopefully follow tomorrow or on the weekend.

@LukeSavefrogs
Copy link
Owner

@LukeSavefrogs
I created a draft PR, as I didn't have time today to test how my changes play together with yours just yet.
So currently the code changes are just there for you to review if you want.
Automated tests should hopefully follow tomorrow or on the weekend.

Thank you! I'll take a look 😄

@kaz-utashiro
Copy link

I stopped here by chance.
There is a wonderful command called teip (https://github.com/greymd/teip).
You can use it like this:

teip -v -g '(^|:)$' -- column -t

Then only lines which does not match the pattern (^|:)$ will be passed to column command and replaced by the result.

BTW, I also have a column-like command which can handle ANSI terminal sequences.
https://github.com/tecolicom/App-ansicolumn

@LukeSavefrogs
Copy link
Owner

BTW, I also have a column-like command which can handle ANSI terminal sequences.
https://github.com/tecolicom/App-ansicolumn

I'll add this project to the list of similar projects.

Thank you for sharing 🎉

LukeSavefrogs added a commit that referenced this issue Apr 13, 2023
LukasWillin added a commit to LukasWillin/column_ansi that referenced this issue Jun 15, 2023
LukasWillin added a commit to LukasWillin/column_ansi that referenced this issue Jun 15, 2023
LukasWillin added a commit to LukasWillin/column_ansi that referenced this issue Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants