colour

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package colour implements basic text colouring for cli's limited needs.

In particular, it's not expected to provide every ANSI code, just the ones we need. The codes have also been padded so that they are the same length, which means text/tabwriter will correctly calculate alignment as long as styles are not mixed within a table.

Index

Constants

View Source
const (
	CodeReset = "\x1b[000000m" // Reset all attributes
	CodeTitle = "\x1b[1;39;4m" // Bold, white & underlined
	CodeBold  = "\x1b[1;0039m" // Bold & white
)

ANSI codes for coloured output, they are all the same length so as not to throw off alignment of text/tabwriter.

Variables

View Source
var Disable atomic.Bool

Disable is a flag that disables all colour text, it overrides both $FORCE_COLOR and $NO_COLOR, setting it to true will always make this package return plain text and not check any other config.

Functions

func Bold

func Bold(text string) string

Bold returns the given text in bold white.

If $NO_COLOR is set, text will be returned unmodified.

func Title

func Title(text string) string

Title returns the given text in a title style, bold white and underlined.

If $NO_COLOR is set, text will be returned unmodified.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL