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

Allow Disabling Prefixes in PrefixPrinters. #170

Closed
jenslauterbach opened this issue Mar 18, 2021 · 7 comments · Fixed by #173
Closed

Allow Disabling Prefixes in PrefixPrinters. #170

jenslauterbach opened this issue Mar 18, 2021 · 7 comments · Fixed by #173
Assignees
Labels
in progress Issues which are currently worked on proposal Proposal to add a new feature to pterm
Milestone

Comments

@jenslauterbach
Copy link

jenslauterbach commented Mar 18, 2021

I am currently trying to use pterm and would like to offer my users an option to output as plain text.

I'd like to use prefix printers (pterm.Info.Println("")) throughout my code, but if I want to offer plain text output, the prefix becomes a problem.

It would be great to have a way to disable prefixes completely using a "global" switch, similar to pterm.DisableColor() or pterm.DisableDebugMessages().

When the switch is used, the following behaviour would be great:

pterm.DisablePrefixes()
pterm.Info.Println("Hello World") // Output: Hello World

pterm.EnablePrefixes()
pterm.Info.Println("Hello World") // Output: [ INFO ] Hello World
@jenslauterbach jenslauterbach added the proposal Proposal to add a new feature to pterm label Mar 18, 2021
@MarvinJWendt
Copy link
Member

Hi @jenslauterbach, thanks for the feedback. Since the feature is very PrefixPrinter specific, I don't think that a global setting would fit here. But, I think a pterm.EnablePlainTextOutput() / pterm.DisbleStyling() method would make sense! This would fit your use case (probably even better) and I totally see the relevance to disable all styling (for raw text files, etc.). Thanks again for the suggestion :)

I will work on this in the next days 👍

@MarvinJWendt MarvinJWendt self-assigned this Mar 19, 2021
@MarvinJWendt MarvinJWendt added this to the v1.0.0 milestone Mar 19, 2021
@jenslauterbach
Copy link
Author

Thank you very much @MarvinJWendt. Much appreciated.

@MarvinJWendt MarvinJWendt added the in progress Issues which are currently worked on label Apr 1, 2021
@MarvinJWendt
Copy link
Member

Hi @jenslauterbach, sorry for the delay. I am in my exam phase so I don't have much time to work on this. We might ship this feature at the end of the month.

@jenslauterbach
Copy link
Author

jenslauterbach commented May 7, 2021

@MarvinJWendt Thank you for the update. No need to explain yourself why it is taking longer. I can wait :)

I wish you the best of luck for your exams 👍

@MarvinJWendt
Copy link
Member

MarvinJWendt commented May 13, 2021

Hi @jenslauterbach, I am currently implementing this.

This is the current functionallity:

Default behaviour

image

pterm.DisableStyling() called before

image

As you can see, the prefixes won't be removed completely, so that users can still get the context of a message in RawOutput mode, and better distinguish between Errors, Warnings and Infos in log files.

If you want to remove the prefixes completely, you could do this:

pterm.DisableStyling()
pterm.Debug.Prefix.Text = ""
pterm.Info.Prefix.Text = ""
pterm.Success.Prefix.Text = ""
pterm.Warning.Prefix.Text = ""
pterm.Error.Prefix.Text = ""
pterm.Fatal.Prefix.Text = ""

image

This would remove every prefix. The problem with that is, that it can't be toggled back without creating a backup of every PrefixPrinter beforehand.

Does this still fit your need?

PS: I will let you know, when the feature is officially released.

@MarvinJWendt
Copy link
Member

So this is now implemented in v0.12.15, let me know if this fits your need and if you find anything else 😄

Styles can be disabled with pterm.DisableStyling()

@jenslauterbach
Copy link
Author

@MarvinJWendt Looks like it will do what I wanted. I will try it as soon as I have some time. Thank you for implementing this new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Issues which are currently worked on proposal Proposal to add a new feature to pterm
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants