From d37380a0b750c6166767d064367ece9ecf0d5d02 Mon Sep 17 00:00:00 2001 From: inhere Date: Thu, 8 Apr 2021 00:31:15 +0800 Subject: [PATCH] update readme --- README.md | 1 + README.zh-CN.md | 6 ++++-- color.go | 34 ++++++++++++++++++++++++++++++++++ style.go | 34 ---------------------------------- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 73511cc..d8d8dc2 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Now, 256 colors and RGB colors have also been supported to work in Windows CMD a - Support working on Windows `cmd` `powerShell` terminal - Basic colors: `Bold`, `Black`, `White`, `Gray`, `Red`, `Green`, `Yellow`, `Blue`, `Magenta`, `Cyan` - Additional styles: `Info`, `Note`, `Light`, `Error`, `Danger`, `Notice`, `Success`, `Comment`, `Primary`, `Warning`, `Question`, `Secondary` + - Support by set `NO_COLOR` for disable color or use `FORCE_COLOR` for force open color render. ## GoDoc diff --git a/README.zh-CN.md b/README.zh-CN.md index ffc6bb4..2c327eb 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -29,10 +29,12 @@ Golang下的命令行色彩使用库, 拥有丰富的色彩渲染输出,通用 - 自 `v1.2.4` 起 **256色(8bit),RGB色彩(24bit)均支持Windows CMD和PowerShell终端** - 请查看 [this gist](https://gist.github.com/XVilka/8346728) 了解支持RGB色彩的终端 - 通用的API方法:`Print` `Printf` `Println` `Sprint` `Sprintf` - - 同时支持html标签式的颜色渲染. eg: `message` + - 同时支持html标签式的颜色渲染. + - 例如: `this an message` 标签内部的文本将会渲染为绿色字体 - 基础色彩: `Bold` `Black` `White` `Gray` `Red` `Green` `Yellow` `Blue` `Magenta` `Cyan` - 扩展风格: `Info` `Note` `Light` `Error` `Danger` `Notice` `Success` `Comment` `Primary` `Warning` `Question` `Secondary` - - 支持Linux、Mac同时兼容Windows系统环境 + - 支持通过设置环境变量 `NO_COLOR` 来禁用色彩,或者使用 `FORCE_COLOR` 来强制使用色彩渲染. + - 支持Linux、Mac,同时兼容Windows系统环境 ## GoDoc diff --git a/color.go b/color.go index 4d3d6c1..da06642 100644 --- a/color.go +++ b/color.go @@ -185,6 +185,40 @@ func InnerErrs() []error { return innerErrs } +/************************************************************* + * quick use color/style print line message + *************************************************************/ + +// Infof print message with Info style +func Infof(format string, a ...interface{}) { + Info.Printf(format, a...) +} + +// Infoln print message with Info style +func Infoln(a ...interface{}) { + Info.Println(a...) +} + +// Errorf print message with Error style +func Errorf(format string, a ...interface{}) { + Error.Printf(format, a...) +} + +// Errorln print message with Error style +func Errorln(a ...interface{}) { + Error.Println(a...) +} + +// Warnf print message with Warn style +func Warnf(format string, a ...interface{}) { + Warn.Printf(format, a...) +} + +// Warnln print message with Warn style +func Warnln(a ...interface{}) { + Warn.Println(a...) +} + /************************************************************* * render color code *************************************************************/ diff --git a/style.go b/style.go index af7456a..fad76fb 100644 --- a/style.go +++ b/style.go @@ -255,40 +255,6 @@ func GetStyle(name string) Style { return New() } -/************************************************************* - * quick use style print message - *************************************************************/ - -// Infof print message with Info style -func Infof(format string, a ...interface{}) { - Info.Printf(format, a...) -} - -// Infoln print message with Info style -func Infoln(a ...interface{}) { - Info.Println(a...) -} - -// Errorf print message with Error style -func Errorf(format string, a ...interface{}) { - Error.Printf(format, a...) -} - -// Errorln print message with Error style -func Errorln(a ...interface{}) { - Error.Println(a...) -} - -// Warnf print message with Warn style -func Warnf(format string, a ...interface{}) { - Warn.Printf(format, a...) -} - -// Warnln print message with Warn style -func Warnln(a ...interface{}) { - Warn.Println(a...) -} - /************************************************************* * color scheme *************************************************************/