You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried to set ctx.color = True as suggested in #1090 in order to enable colour output in Gitlab CI. This worked out great for normal click.secho but unfortunately it does not work for output generated via raising ClickException subclass. Essentially the echo inside ClickException.show() ignores ctx.color.
After some digging, I am almost sure this is because the get_current_context returns None, there is no context when exceptions are handled:
If I am correct that the context is already closed while handling the exception then I guess it is not so easy to fix. In such a case, could you propose a WAR for that?
I have tried to set
ctx.color = True
as suggested in #1090 in order to enable colour output in Gitlab CI. This worked out great for normalclick.secho
but unfortunately it does not work for output generated via raisingClickException
subclass. Essentially theecho
insideClickException.show()
ignoresctx.color
.After some digging, I am almost sure this is because the
get_current_context
returnsNone
, there is no context when exceptions are handled:click/src/click/globals.py
Line 63 in 49164fa
Test code
Test cases
python test.py
python test.py --ansi
python test.py &> test.log; cat test.log
python test.py --ansi &> test.log; cat test.log
Expected behaviour
In all cases except 3) there is a green
some output
and redsome error
in output.In 3) there is no colouring.
Actual behaviour
Everything is as expected except 4) where
some error
is not coloured.Environment
The text was updated successfully, but these errors were encountered: