Clap has a few extra tools that may be useful when creating your applications.
The clap.ansi.ANSI class can be used to format your output with ANSI color and text effects.
This is capable of handling the majority of widely-supported SGR codes. It is instantiated with a stream, but if the stream is None, it will merely return the codes generated instead of write them.
Parameter: | stream – The stream to write to. If it is None, the codes will be returned. |
---|
Sets the background color to the given color.
Parameter: | color – The color to set. (Can be an int from 1-7 or a str.) |
---|
Sets the foreground color to the given color.
Parameter: | color – The color to set. (Can be an int from 1-7 or a str.) |
---|
This writes data to the stream. If the stream is None, it just returns the data. If the data is an int, it will wrap it in an escape code before printing.
Parameter: | data – The data to write, or an int SGR code. |
---|
Two instances of this class are provided.