kennethreitz / clint

Python Command-line Application Tools
http://pypi.python.org/pypi/clint/
ISC License
95 stars 19 forks source link

Support bold (or underline) text with no color specification #157

Open dandavison opened 8 years ago

dandavison commented 8 years ago

It would be useful to be able to specify bold text without specifying a color (so the default foreground color will be used which will be compatible with the current terminal color scheme). A quick version based on how clint does colors:

def default_color(s, always=False, bold=False):
    if bold and (always or sys.stdout.isatty()):
        return '{on}{string}{off}'.format(
            on=getattr(colorama.Style, 'BRIGHT'),
            string=s,
            off=getattr(colorama.Style, 'NORMAL'))
    else:
        return s