Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 10, 2021
1 parent cf0234a commit 971acbd
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 168 deletions.
139 changes: 62 additions & 77 deletions README.md
Expand Up @@ -94,6 +94,8 @@ func main() {

// use style tag
color.Print("<suc>he</><comment>llo</>, <cyan>wel</><red>come</>\n")
// Custom label attr: Supports the use of 16 color names, 256 color values, rgb color values and hex color values
color.Println("<fg=11aa23>he</><bg=120,35,156>llo</>, <fg=167;bg=232>wel</><fg=red>come</>")

// apply a style tag
color.Tag("info").Println("info style text")
Expand All @@ -112,14 +114,34 @@ Run demo: `go run ./_examples/demo.go`

![colored-out](_examples/images/color-demo.jpg)

## Custom Build Color
## Basic/16 color

Supported on any Windows version. Provide generic API methods: `Print`, `Printf`, `Println`, `Sprint`, `Sprintf`

```go
color.Bold.Println("bold message")
color.Black.Println("bold message")
color.White.Println("bold message")
color.Gray.Println("bold message")
color.Red.Println("yellow message")
color.Blue.Println("yellow message")
color.Cyan.Println("yellow message")
color.Yellow.Println("yellow message")
color.Magenta.Println("yellow message")

// Only use foreground color
color.FgCyan.Printf("Simple to use %s\n", "color")
// Only use background color
color.BgRed.Printf("Simple to use %s\n", "color")
```

Run demo: `go run ./_examples/color_16.go`

![basic-color](_examples/images/basic-color.png)

### Custom build color

```go
// Full custom: foreground, background, option
myStyle := color.New(color.FgWhite, color.BgBlack, color.OpBold)
myStyle.Println("custom color style")
Expand All @@ -141,49 +163,9 @@ fmt.Print("message")
color.Reset()
```

## Basic Color
### Additional styles

Supported on any Windows version.

- `color.Bold`
- `color.Black`
- `color.White`
- `color.Gray`
- `color.Red`
- `color.Green`
- `color.Yellow`
- `color.Blue`
- `color.Magenta`
- `color.Cyan`

```go
color.Bold.Println("bold message")
color.Yellow.Println("yellow message")
```

Run demo: `go run ./_examples/color_16.go`

![basic-color](_examples/images/basic-color.png)

## Additional styles

Supported on any Windows version.

- `color.Info`
- `color.Note`
- `color.Warn`
- `color.Light`
- `color.Error`
- `color.Danger`
- `color.Debug`
- `color.Notice`
- `color.Success`
- `color.Comment`
- `color.Primary`
- `color.Question`
- `color.Secondary`

### Basic Style
provide generic API methods: `Print`, `Printf`, `Println`, `Sprint`, `Sprintf`

print message use defined style:

Expand All @@ -204,7 +186,7 @@ Run demo: `go run ./_examples/theme_basic.go`

![theme-basic](_examples/images/theme-basic.png)

### Tips Style
**Tips style**

```go
color.Info.Tips("Info tips message")
Expand All @@ -223,7 +205,7 @@ Run demo: `go run ./_examples/theme_tips.go`

![theme-tips](_examples/images/theme-tips.png)

### Prompt Style
**Prompt Style**

```go
color.Info.Prompt("Info prompt message")
Expand All @@ -242,7 +224,7 @@ Run demo: `go run ./_examples/theme_prompt.go`

![theme-prompt](_examples/images/theme-prompt.png)

### Block Style
**Block Style**

```go
color.Info.Block("Info block message")
Expand All @@ -261,34 +243,6 @@ Run demo: `go run ./_examples/theme_block.go`

![theme-block](_examples/images/theme-block.png)

## HTML-like tag usage

**Supported** on Windows `cmd.exe` `PowerShell` .

```go
// use style tag
color.Print("<suc>he</><comment>llo</>, <cyan>wel</><red>come</>")
color.Println("<suc>hello</>")
color.Println("<error>hello</>")
color.Println("<warning>hello</>")

// custom color attributes
color.Print("<fg=yellow;bg=black;op=underscore;>hello, welcome</>\n")
```

- `color.Tag`

```go
// set a style tag
color.Tag("info").Print("info style text")
color.Tag("info").Printf("%s style text", "info")
color.Tag("info").Println("info style text")
```

Run demo: `go run ./_examples/color_tag.go`

![color-tags](_examples/images/color-tags.png)

## 256-color usage

> 256 colors support Windows CMD, PowerShell environment after `v1.2.4`
Expand All @@ -307,7 +261,7 @@ c.Println("message")
c.Printf("format %s", "message")
```

### Use a 256-color style
### 256-color style

Can be used to set foreground and background colors at the same time.

Expand All @@ -333,7 +287,7 @@ Run demo: `go run ./_examples/color_256.go`

![color-tags](_examples/images/color-256.png)

## Use RGB color
## RGB/True color

> RGB colors support Windows `CMD`, `PowerShell` environment after `v1.2.4`
Expand Down Expand Up @@ -383,7 +337,7 @@ c.Println("message")
c.Printf("format %s", "message")
```

### Use an RGB color style
### RGB color style

Can be used to set the foreground and background colors at the same time.

Expand Down Expand Up @@ -415,6 +369,37 @@ s.Println("style with options")
s.Printf("style with %s\n", "options")
```

## HTML-like tag usage

**Supported** on Windows `cmd.exe` `PowerShell` .

```go
// use style tag
color.Print("<suc>he</><comment>llo</>, <cyan>wel</><red>come</>")
color.Println("<suc>hello</>")
color.Println("<error>hello</>")
color.Println("<warning>hello</>")

// custom color attributes
color.Print("<fg=yellow;bg=black;op=underscore;>hello, welcome</>\n")

// Custom label attr: Supports the use of 16 color names, 256 color values, rgb color values and hex color values
color.Println("<fg=11aa23>he</><bg=120,35,156>llo</>, <fg=167;bg=232>wel</><fg=red>come</>")
```

- `color.Tag`

```go
// set a style tag
color.Tag("info").Print("info style text")
color.Tag("info").Printf("%s style text", "info")
color.Tag("info").Println("info style text")
```

Run demo: `go run ./_examples/color_tag.go`

![color-tags](_examples/images/color-tags.png)

## Color convert

Supports conversion between Rgb, 256, 16 colors, `Rgb <=> 256 <=> 16`
Expand Down

0 comments on commit 971acbd

Please sign in to comment.