From d94c70e319526097b6a806d540fc702e4734ace3 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Sun, 18 Oct 2020 17:00:45 -0500 Subject: [PATCH] Add license and fix READMEs Signed-off-by: jolheiser --- LICENSE | 7 +++++++ README.md | 6 +++++- color/README.md | 35 +++++++---------------------------- 3 files changed, 19 insertions(+), 29 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0f02641 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2020 John Olheiser + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index daa4c77..d2d613e 100644 --- a/README.md +++ b/README.md @@ -50,4 +50,8 @@ Beaver allows you to customize the colors of various parts of the message color.Trace = color.New(color.FgMagenta) ``` -[More info for the `color` package](color/README.md) \ No newline at end of file +[More info for the `color` package](color/README.md) + +## LICENSE + +[MIT](LICENSE) \ No newline at end of file diff --git a/color/README.md b/color/README.md index 1557d77..d304518 100644 --- a/color/README.md +++ b/color/README.md @@ -2,6 +2,9 @@ Beaver comes with the `color` sub-package that can be used even without Beaver calls. +`Color` is an interface that simply needs `Format(text string) string` to fulfill it. +Any logger in beaver can be set to a `Color`. + ## Formatting a string with a single attribute ```go text := color.FgRed.Format("red") @@ -12,34 +15,10 @@ text := color.FgRed.Format("red") text := color.New(color.BgGreen, color.FgRed, color.Bold).Format("green background, red text, and bold") ``` -## Formatting strings with multiple colors -The following are different ways to print `This is a color test!` -where the word `color` is red while everything else is `green`. +## Extended colors -### setup -Assuming each example is preceded by -```go -green := color.New(color.FgGreen) -red := color.New(color.FgRed) -``` +Extended colors are 256-color extensions. They can be referred to by name, available in [extended_colors.go](extended_colors.go). -#### pure `fmt.Println` -```go -fmt.Println(green.Format("This is a"), red.Format("color"), green.Format("test!")) -``` +## True colors -#### `color.Wrap` -```go -fmt.Println(green.Wrap("This is a #{color} test!", red)) -``` - -#### string formatting with `fmt.Printf` and `color.Wrap` -```go -fmt.Printf(green.Wrap("This is a #{%s} test!\n", red), "color") -``` - -#### using a different directive prefix -```go -color.DirectivePrefix('$') -fmt.Printf(green.Wrap("This is a ${%s} test!\n", red), "color") -``` \ No newline at end of file +True colors are full RBG colors, they can be either created with RGB values or parsed from hex. \ No newline at end of file