Browse Source

Fixed a typo

Signed-off-by: Vishal Rana <vr@labstack.com>
Vishal Rana 10 years ago
parent
commit
3dc2d67251
4 changed files with 68 additions and 39 deletions
  1. 2 2
      color/README.md
  2. 63 35
      color/color.go
  3. 2 2
      color/color_test.go
  4. 1 0
      gytes/gytes.go

+ 2 - 2
color/README.md

@@ -65,9 +65,9 @@ fmt.Println(color.Strikeout("strikeout"))
 ```go
 ```go
 fmt.Println(color.Green("bold green with white background", color.B, color.WhtBg))
 fmt.Println(color.Green("bold green with white background", color.B, color.WhtBg))
 fmt.Println(color.Red("underline red", color.U))
 fmt.Println(color.Red("underline red", color.U))
-fmt.Println(color.Yellow("dim yellow", color.Dm))
+fmt.Println(color.Yellow("dim yellow", color.D))
 fmt.Println(color.Cyan("inverse cyan", color.In))
 fmt.Println(color.Cyan("inverse cyan", color.In))
-fmt.Println(color.Blue("bold underline dim blue", color.B, color.U, color.Dm))
+fmt.Println(color.Blue("bold underline dim blue", color.B, color.U, color.D))
 ```
 ```
 ![Mix and match](http://i.imgur.com/jWGq9Ca.png)
 ![Mix and match](http://i.imgur.com/jWGq9Ca.png)
 
 

+ 63 - 35
color/color.go

@@ -47,26 +47,53 @@ const (
 	// WhtBg white background style
 	// WhtBg white background style
 	WhtBg = "47"
 	WhtBg = "47"
 
 
-	// Rst reset emphasis style
-	Rst = "0"
+	// R reset emphasis style
+	R = "0"
 	// B bold emphasis style
 	// B bold emphasis style
 	B = "1"
 	B = "1"
-	// Dm dim emphasis style
-	Dm = "2"
+	// D dim emphasis style
+	D = "2"
 	// I italic emphasis style
 	// I italic emphasis style
 	I = "3"
 	I = "3"
 	// U underline emphasis style
 	// U underline emphasis style
 	U = "4"
 	U = "4"
 	// In inverse emphasis style
 	// In inverse emphasis style
 	In = "7"
 	In = "7"
-	// Hd hidden emphasis style
-	Hd = "8"
-	// So strikeout emphasis style
-	So = "9"
+	// H hidden emphasis style
+	H = "8"
+	// S strikeout emphasis style
+	S = "9"
 )
 )
 
 
-// Color functions
 var (
 var (
+	black   = outer(Blk)
+	red     = outer(Rd)
+	green   = outer(Grn)
+	yellow  = outer(Yel)
+	blue    = outer(Blu)
+	magenta = outer(Mgn)
+	cyan    = outer(Cyn)
+	white   = outer(Wht)
+	grey    = outer(Gry)
+
+	blackBg   = outer(BlkBg)
+	redBg     = outer(RdBg)
+	greenBg   = outer(GrnBg)
+	yellowBg  = outer(YelBg)
+	blueBg    = outer(BluBg)
+	magentaBg = outer(MgnBg)
+	cyanBg    = outer(CynBg)
+	whiteBg   = outer(WhtBg)
+
+	reset     = outer(R)
+	bolt      = outer(B)
+	dim       = outer(D)
+	italic    = outer(I)
+	underline = outer(U)
+	inverse   = outer(In)
+	hidden    = outer(H)
+	strikeout = outer(S)
+
 	global = New()
 	global = New()
 )
 )
 
 
@@ -90,108 +117,109 @@ type (
 	}
 	}
 )
 )
 
 
+// New creates a Color instance.
 func New() *Color {
 func New() *Color {
 	return &Color{}
 	return &Color{}
 }
 }
 
 
 func (c *Color) Black(msg interface{}, styles ...string) string {
 func (c *Color) Black(msg interface{}, styles ...string) string {
-	return outer(Blk)(msg, styles)
+	return black(msg, styles)
 }
 }
 
 
 func (c *Color) Red(msg interface{}, styles ...string) string {
 func (c *Color) Red(msg interface{}, styles ...string) string {
-	return outer(Rd)(msg, styles)
+	return red(msg, styles)
 }
 }
 
 
 func (c *Color) Green(msg interface{}, styles ...string) string {
 func (c *Color) Green(msg interface{}, styles ...string) string {
-	return outer(Grn)(msg, styles)
+	return green(msg, styles)
 }
 }
 
 
 func (c *Color) Yellow(msg interface{}, styles ...string) string {
 func (c *Color) Yellow(msg interface{}, styles ...string) string {
-	return outer(Yel)(msg, styles)
+	return yellow(msg, styles)
 }
 }
 
 
 func (c *Color) Blue(msg interface{}, styles ...string) string {
 func (c *Color) Blue(msg interface{}, styles ...string) string {
-	return outer(Blu)(msg, styles)
+	return blue(msg, styles)
 }
 }
 
 
 func (c *Color) Magenta(msg interface{}, styles ...string) string {
 func (c *Color) Magenta(msg interface{}, styles ...string) string {
-	return outer(Mgn)(msg, styles)
+	return magenta(msg, styles)
 }
 }
 
 
 func (c *Color) Cyan(msg interface{}, styles ...string) string {
 func (c *Color) Cyan(msg interface{}, styles ...string) string {
-	return outer(Cyn)(msg, styles)
+	return cyan(msg, styles)
 }
 }
 
 
 func (c *Color) White(msg interface{}, styles ...string) string {
 func (c *Color) White(msg interface{}, styles ...string) string {
-	return outer(Wht)(msg, styles)
+	return white(msg, styles)
 }
 }
 
 
 func (c *Color) Grey(msg interface{}, styles ...string) string {
 func (c *Color) Grey(msg interface{}, styles ...string) string {
-	return outer(Gry)(msg, styles)
+	return grey(msg, styles)
 }
 }
 
 
 func (c *Color) BlackBg(msg interface{}, styles ...string) string {
 func (c *Color) BlackBg(msg interface{}, styles ...string) string {
-	return outer(BlkBg)(msg, styles)
+	return blackBg(msg, styles)
 }
 }
 
 
 func (c *Color) RedBg(msg interface{}, styles ...string) string {
 func (c *Color) RedBg(msg interface{}, styles ...string) string {
-	return outer(RdBg)(msg, styles)
+	return redBg(msg, styles)
 }
 }
 
 
 func (c *Color) GreenBg(msg interface{}, styles ...string) string {
 func (c *Color) GreenBg(msg interface{}, styles ...string) string {
-	return outer(GrnBg)(msg, styles)
+	return greenBg(msg, styles)
 }
 }
 
 
 func (c *Color) YellowBg(msg interface{}, styles ...string) string {
 func (c *Color) YellowBg(msg interface{}, styles ...string) string {
-	return outer(YelBg)(msg, styles)
+	return yellowBg(msg, styles)
 }
 }
 
 
 func (c *Color) BlueBg(msg interface{}, styles ...string) string {
 func (c *Color) BlueBg(msg interface{}, styles ...string) string {
-	return outer(BluBg)(msg, styles)
+	return blueBg(msg, styles)
 }
 }
 
 
 func (c *Color) MagentaBg(msg interface{}, styles ...string) string {
 func (c *Color) MagentaBg(msg interface{}, styles ...string) string {
-	return outer(MgnBg)(msg, styles)
+	return magentaBg(msg, styles)
 }
 }
 
 
 func (c *Color) CyanBg(msg interface{}, styles ...string) string {
 func (c *Color) CyanBg(msg interface{}, styles ...string) string {
-	return outer(CynBg)(msg, styles)
+	return cyanBg(msg, styles)
 }
 }
 
 
 func (c *Color) WhiteBg(msg interface{}, styles ...string) string {
 func (c *Color) WhiteBg(msg interface{}, styles ...string) string {
-	return outer(WhtBg)(msg, styles)
+	return whiteBg(msg, styles)
 }
 }
 
 
 func (c *Color) Reset(msg interface{}, styles ...string) string {
 func (c *Color) Reset(msg interface{}, styles ...string) string {
-	return outer(Rst)(msg, styles)
+	return reset(msg, styles)
 }
 }
 
 
 func (c *Color) Bold(msg interface{}, styles ...string) string {
 func (c *Color) Bold(msg interface{}, styles ...string) string {
-	return outer(B)(msg, styles)
+	return bolt(msg, styles)
 }
 }
 
 
 func (c *Color) Dim(msg interface{}, styles ...string) string {
 func (c *Color) Dim(msg interface{}, styles ...string) string {
-	return outer(Dm)(msg, styles)
+	return dim(msg, styles)
 }
 }
 
 
 func (c *Color) Italic(msg interface{}, styles ...string) string {
 func (c *Color) Italic(msg interface{}, styles ...string) string {
-	return outer(I)(msg, styles)
+	return italic(msg, styles)
 }
 }
 
 
 func (c *Color) Underline(msg interface{}, styles ...string) string {
 func (c *Color) Underline(msg interface{}, styles ...string) string {
-	return outer(U)(msg, styles)
+	return underline(msg, styles)
 }
 }
 
 
 func (c *Color) Inverse(msg interface{}, styles ...string) string {
 func (c *Color) Inverse(msg interface{}, styles ...string) string {
-	return outer(In)(msg, styles)
+	return inverse(msg, styles)
 }
 }
 
 
 func (c *Color) Hidden(msg interface{}, styles ...string) string {
 func (c *Color) Hidden(msg interface{}, styles ...string) string {
-	return outer(Hd)(msg, styles)
+	return hidden(msg, styles)
 }
 }
 
 
 func (c *Color) Strikeout(msg interface{}, styles ...string) string {
 func (c *Color) Strikeout(msg interface{}, styles ...string) string {
-	return outer(So)(msg, styles)
+	return strikeout(msg, styles)
 }
 }
 
 
 func Black(msg interface{}, styles ...string) string {
 func Black(msg interface{}, styles ...string) string {
@@ -283,7 +311,7 @@ func Underline(msg interface{}, styles ...string) string {
 }
 }
 
 
 func Inverse(msg interface{}, styles ...string) string {
 func Inverse(msg interface{}, styles ...string) string {
-	return global.Underline(msg, styles...)
+	return global.Inverse(msg, styles...)
 }
 }
 
 
 func Hidden(msg interface{}, styles ...string) string {
 func Hidden(msg interface{}, styles ...string) string {

+ 2 - 2
color/color_test.go

@@ -46,7 +46,7 @@ func TestMixMatch(t *testing.T) {
 	fmt.Println("*** mix and match ***")
 	fmt.Println("*** mix and match ***")
 	fmt.Println(Green("bold green with white background", B, WhtBg))
 	fmt.Println(Green("bold green with white background", B, WhtBg))
 	fmt.Println(Red("underline red", U))
 	fmt.Println(Red("underline red", U))
-	fmt.Println(Yellow("dim yellow", Dm))
+	fmt.Println(Yellow("dim yellow", D))
 	fmt.Println(Cyan("inverse cyan", In))
 	fmt.Println(Cyan("inverse cyan", In))
-	fmt.Println(Blue("bold underline dim blue", B, U, Dm))
+	fmt.Println(Blue("bold underline dim blue", B, U, D))
 }
 }

+ 1 - 0
gytes/gytes.go

@@ -16,6 +16,7 @@ type (
 	}
 	}
 )
 )
 
 
+// New creates a Gytes instance.
 func New() *Gytes {
 func New() *Gytes {
 	return &Gytes{}
 	return &Gytes{}
 }
 }