Skip to content

Commit

Permalink
♻️ Update
Browse files Browse the repository at this point in the history
  • Loading branch information
UltiRequiem committed Apr 6, 2022
1 parent 645b0fe commit b1fdfed
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func parametersAndFlags() (bool, bool, []string) {
}

func printHelp() {
chigo.PrintWithColors(fmt.Sprintf(HELP_MESSAGE, VERSION))
fmt.Println(chigo.Colorize(fmt.Sprintf(HELP_MESSAGE, VERSION)))
}

const VERSION = "1.0.0"
Expand Down
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"github.com/UltiRequiem/chigo/internal"

chigo "github.com/UltiRequiem/chigo/pkg"
Expand All @@ -23,11 +24,11 @@ func Main() {
data, error := internal.JoinFiles(files)

if error != nil {
chigo.PrintWithColors(error.Error())
fmt.Println(chigo.Colorize(error.Error()))
return
}

chigo.PrintWithColors(data)
fmt.Println(chigo.Colorize(data))
return
}

Expand Down
4 changes: 3 additions & 1 deletion example/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"fmt"

chigo "github.com/UltiRequiem/chigo/pkg"
)

func main() {
chigo.PrintWithColors("Hello, World!")
fmt.Println(chigo.Colorize("Hello, World!"))
}
2 changes: 1 addition & 1 deletion internal/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func StartProcessFromStdin() {
input, _, err := reader.ReadRune()

if err != nil {
chigo.PrintWithColors(err.Error())
fmt.Println(chigo.Colorize(err.Error()))
break
}

Expand Down
2 changes: 1 addition & 1 deletion license.md β†’ license
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MIT License
MIT License

Copyright (c) 2022 Eliaz Bobadilla <[email protected]>
(https://ultirequiem.com)
Expand Down
8 changes: 6 additions & 2 deletions pkg/printWithColors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ import (
"strings"
)

func PrintWithColors(text string) {
func Colorize(text string) string {
scanner := bufio.NewScanner(strings.NewReader(text))

result := ""

for i := 1.0; scanner.Scan(); i++ {
rgb := NewRGB(i)

fmt.Printf("\033[38;2;%d;%d;%dm%s\033[0m\n", rgb.Red, rgb.Green, rgb.Blue, scanner.Text())
result += fmt.Sprintf("\033[38;2;%d;%d;%dm%s\033[0m\n", rgb.Red, rgb.Green, rgb.Blue, scanner.Text())
}

return result
}
18 changes: 11 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

![Screenshot](./assets/screenshot.png)

[YouTube Video](https://youtu.be/4Bc-aBfjxwY)
[Video](https://youtu.be/4Bc-aBfjxwY) πŸ“Ή

## Installation

Expand All @@ -28,22 +28,21 @@ It also exports utils to output with colors in your own CLI Tools.
package main

import (
"fmt"
chigo "github.com/UltiRequiem/chigo/pkg"
)

func main() {
chigo.PrintWithColors("Hello, World!")
fmt.Println(chigo.Colorize("Hello, World!"))
}
```

> [A more complete example](https://github.com/UltiRequiem/lorelai/tree/main/cmd/utils.go)
> πŸ•΅οΈβ€β™‚οΈ
[Autogenerated documentation](https://pkg.go.dev/github.com/UltiRequiem/chigo/pkg)
πŸ“‘
[Autogenerated docs](https://pkg.go.dev/github.com/UltiRequiem/chigo/pkg) πŸ“‘

[I also made a little blog about this project](https://blog.ultirequiem.com/chigo)
πŸš€
[I also made a blog about this project](https://blog.ultirequiem.com/chigo) πŸš€

## Support

Expand All @@ -57,6 +56,11 @@ my work πŸš€

Don't forget to start the repo ⭐

## Versioning

We use [Semantic Versioning](http://semver.org). For the versions available, see
the [tags](https://github.com/UltiRequiem/chigo/tags) 🏷️

## Authors

[Eliaz Bobadilla (a.k.a UltiRequiem)](https://ultirequiem.com) - Creator and
Expand All @@ -68,4 +72,4 @@ participated in this project.

## Licence

Licensed under the MIT License.
Licensed under the MIT License πŸ“„

0 comments on commit b1fdfed

Please sign in to comment.