Skip to content

Commit

Permalink
Go Docs [Terminal] [Colorize] Update Documentation (#21)
Browse files Browse the repository at this point in the history
* Go Docs [Terminal] [Colorize] Update Documentation

- [+] docs(colorize.go): update function description and add note about Windows Command Prompt support

* Docs [README] Screenshot section

- [+] docs(README.md): add screenshot section with an image of the GoGenAI Terminal Chat application
- [+] docs(README.md): update example section to fix a typo
  • Loading branch information
H0llyW00dzZ authored Jan 4, 2024
1 parent ba661b2 commit c7ddc91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ This command will start the GoGenAI Terminal Chat application in interactive mod
- `API_KEY`: Your API key for accessing the generative AI model. This is a required environment variable.


## Screenshot

<p align="center">
<img src="https://i.imgur.com/H9vDYjZ.png" alt="kubectl terminal" />
</p>


## Example how it work

🤓 You: hello are you ?
Expand Down
9 changes: 7 additions & 2 deletions terminal/colorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const (
ColorReset = "\033[0m"
)

// Colorize applies ANSI color codes to the text between pairs of delimiters.
// It supports multiple delimiters and their corresponding colors.
// Colorize applies ANSI color codes to the text surrounded by specified delimiters.
// It can process multiple delimiters, each with a corresponding color. The function
// can also conditionally retain or remove the delimiters in the final output.
//
// Parameters:
//
Expand All @@ -29,6 +30,10 @@ const (
// Returns:
//
// string: The colorized text.
//
// Note: This function may not work as expected in Windows Command Prompt due to its limited
// support for ANSI color codes. It is designed for terminals that support ANSI, such as those
// in Linux/Unix environments.
func Colorize(text string, colorPairs []string, keepDelimiters map[string]bool) string {
for i := 0; i < len(colorPairs); i += 2 {
delimiter := colorPairs[i]
Expand Down

0 comments on commit c7ddc91

Please sign in to comment.