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

Adding formats to configuration, closes #94 #488

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mapio
Copy link

@mapio mapio commented Nov 30, 2022

This PR adds a formats configuration section that can contain configuration for colors (and other) used by click.style.

@@ -581,3 +581,9 @@ def rename_tag(self, old_tag, new_tag):

self.frames.changed = True
self.save()

def style(self = None, name = 'error', element = None):
if isinstance(self, Watson):
Copy link
Author

Choose a reason for hiding this comment

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

This is an hack, I should have probably commented it in the code. Here is the rationale.

Having self default to None is a way to have both (sort of) a class method (used in case the object has not yet been instantiated, for instance by exceptions in cli) and an instance method.

If called as Watson.style this will not attempt to look at the config property of the uninstantiated object; on the other hand, if watson is an instance of Watson, then watson.style will be able to access the configured formats.

@mapio mapio mentioned this pull request Dec 2, 2022
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.

None yet

1 participant