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

Feature Request: Easy method for disabling color output #449

Open
trevor-vaughan opened this issue Jun 9, 2023 · 11 comments
Open

Feature Request: Easy method for disabling color output #449

trevor-vaughan opened this issue Jun 9, 2023 · 11 comments
Labels
enhancement New feature or request

Comments

@trevor-vaughan
Copy link

I would like to be able to easily disable all colors when printing a table.

Something like colorMap: false or colorMap: {} would be great.

@trevor-vaughan
Copy link
Author

I managed to work around it using myTable.table.colorMap = {} but that seems like a horrible hack.

Setting colorMap: {} when creating a new table does not seem to do what I expect (I'm assuming there's an underlying merge going on).

@ayonious
Copy link
Owner

ayonious commented Jun 18, 2023

You can override the existing default colors like this. Since its typescript all the existing colors can be found easily for autofilling.

const p = new Table({
  colorMap: {
   'red': '',
   'green': '',
   'yellow': '',
   'white': '',
   'blue': '',
   'magenta': '',
   'cyan': '',
   'crimson': '',
   'white_bold': '',
   'reset': ''
  },
});

@ayonious
Copy link
Owner

I don't see any vast application of having a feature to disable all colors quickly.

Since there is already a colorMap to write your own definition of color any time, as long it lets you disable the existing color I think its acceptable.

@trevor-vaughan
Copy link
Author

@ayonious Unfortunately, a custom color map means that an update to the built-in could cause my output to contain unexpected results.

In my case, I'm using the library to generate console tables by default and Markdown tables as an option. This works great except for the color codes.

While I did find the workaround, a built-in at table creation time would be a nice feature.

@ayonious ayonious added the enhancement New feature or request label Jun 27, 2023
@ayonious
Copy link
Owner

ayonious commented Jul 2, 2023

I wont enhance the Default colors much, so dont worry about that. Its meant to help people on simplest cases. So feel free to disable them one by one.

If this feature is requested by more people I will take a look at this.

@ayonious
Copy link
Owner

ayonious commented Jul 6, 2023

On Another thought this is an interesting feature that can also help here:
#426

@jdmarshall
Copy link
Contributor

jdmarshall commented Oct 11, 2023

@ayonious Because color looks like garbage in CI/CD:

build	11-Oct-2023 22:24:23	┌────────────────────────────────────┬─────────┬───────────┬────────┬─────────┐
build	11-Oct-2023 22:24:23	│ �[0m�[01m                         Task Name�[0m │ �[0m�[01mops/sec�[0m │ �[0m�[01mTime (µs)�[0m │ �[0m�[01mMargin�[0m │ �[0m�[01mSamples�[0m │
build	11-Oct-2023 22:24:23	├────────────────────────────────────┼─────────┼───────────┼────────┼─────────┤
build	11-Oct-2023 22:24:23	│ �[0m                 TimedEvent.time()�[0m │ �[0m631,969�[0m │ �[0m    1.582�[0m │ �[0m±0.21%�[0m │ �[0m2527879�[0m │
build	11-Oct-2023 22:24:23	│ �[0m                       statsInfo()�[0m │ �[0m184,013�[0m │ �[0m    5.434�[0m │ �[0m±0.11%�[0m │ �[0m 736056�[0m │
build	11-Oct-2023 22:24:23	│ �[0m                  processMessage()�[0m │ �[0m 19,868�[0m │ �[0m   50.330�[0m │ �[0m±0.12%�[0m │ �[0m  79476�[0m │
build	11-Oct-2023 22:24:23	│ �[0m       constructor (memory - warm)�[0m │ �[0m283,339�[0m │ �[0m    3.529�[0m │ �[0m±0.18%�[0m │ �[0m1133360�[0m │

@ayonious
Copy link
Owner

Makes total sense it will be priotized soon and I will work on this soon. Any PR is welcome

@jdmarshall
Copy link
Contributor

jdmarshall commented Oct 19, 2023

I was thinking about that. Do you think a color: false opt would be appropriate? If so I might be able to make that happen.

Since I ended up moving the formatting code to a library we have for build-time operations, I imported a library that detects if the terminal supports color and I am overriding the colorMap one way if not, and another (eliminating white, which is illegible on an OS X default terminal color scheme) if it does.

I don't think you want to sprout a new dep just for this, yeah?

jdmarshall added a commit to cobblers-children/console-table-printer that referenced this issue Nov 4, 2023
@jdmarshall
Copy link
Contributor

@trevor-vaughan this work for you?

@ayonious
Copy link
Owner

ayonious commented Nov 4, 2023

Sorry for delayed response @jdmarshall

I don't think you want to sprout a new dep just for this, yeah?

Ya I would not add another dependency just for this.

And for the var I just commented on the PR you made. Thanks a lot for your contribution :)

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