-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Black and Underline #7
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,133 @@ | ||
package color | ||
|
||
var ( | ||
Reset = "\033[0m" | ||
Bold = "\033[1m" | ||
Red = "\033[31m" | ||
Green = "\033[32m" | ||
Yellow = "\033[33m" | ||
Blue = "\033[34m" | ||
Purple = "\033[35m" | ||
Cyan = "\033[36m" | ||
Gray = "\033[37m" | ||
White = "\033[97m" | ||
Reset = "\033[0m" | ||
Bold = "\033[1m" | ||
Underline = "\033[4m" | ||
Black = "\033[30m" | ||
Red = "\033[31m" | ||
Green = "\033[32m" | ||
Yellow = "\033[33m" | ||
Blue = "\033[34m" | ||
Purple = "\033[35m" | ||
Cyan = "\033[36m" | ||
Gray = "\033[37m" | ||
White = "\033[97m" | ||
) | ||
|
||
// Ize is an alias for the Colorize function | ||
// | ||
// Example: | ||
// println(color.Ize(color.Red, "This is red")) | ||
// | ||
// println(color.Ize(color.Red, "This is red")) | ||
func Ize(color, s string) string { | ||
return Colorize(color, s) | ||
} | ||
|
||
// Colorize wraps a given message in a given color. | ||
// | ||
// Example: | ||
// println(color.Colorize(color.Red, "This is red")) | ||
// | ||
// println(color.Colorize(color.Red, "This is red")) | ||
func Colorize(color, s string) string { | ||
return color + s + Reset | ||
} | ||
|
||
// InBold wraps the given string s in Bold | ||
// | ||
// Example: | ||
// println(color.InBold("This is bold")) | ||
// | ||
// println(color.InBold("This is bold")) | ||
func InBold(s string) string { | ||
return Colorize(Bold, s) | ||
} | ||
|
||
// InUnderline wraps the given string s in Underline | ||
// | ||
// Example: | ||
// | ||
// println(color.InUnderline("This is underlined")) | ||
func InUnderline(s string) string { | ||
return Colorize(Underline, s) | ||
} | ||
|
||
// InBlack wraps the given string s in Black | ||
// | ||
// Example: | ||
// | ||
// println(color.InBlack("This is black")) | ||
func InBlack(s string) string { | ||
return Colorize(Black, s) | ||
} | ||
|
||
// InRed wraps the given string s in Red | ||
// | ||
// Example: | ||
// println(color.InRed("This is red")) | ||
// | ||
// println(color.InRed("This is red")) | ||
func InRed(s string) string { | ||
return Colorize(Red, s) | ||
} | ||
|
||
// InGreen wraps the given string s in Green | ||
// | ||
// Example: | ||
// println(color.InGreen("This is green")) | ||
// | ||
// println(color.InGreen("This is green")) | ||
func InGreen(s string) string { | ||
return Colorize(Green, s) | ||
} | ||
|
||
// InYellow wraps the given string s in Yellow | ||
// | ||
// Example: | ||
// println(color.InYellow("This is yellow")) | ||
// | ||
// println(color.InYellow("This is yellow")) | ||
func InYellow(s string) string { | ||
return Colorize(Yellow, s) | ||
} | ||
|
||
// InBlue wraps the given string s in Blue | ||
// | ||
// Example: | ||
// println(color.InBlue("This is blue")) | ||
// | ||
// println(color.InBlue("This is blue")) | ||
func InBlue(s string) string { | ||
return Colorize(Blue, s) | ||
} | ||
|
||
// InPurple wraps the given string s in Purple | ||
// | ||
// Example: | ||
// println(color.InPurple("This is purple")) | ||
// | ||
// println(color.InPurple("This is purple")) | ||
func InPurple(s string) string { | ||
return Colorize(Purple, s) | ||
} | ||
|
||
// InCyan wraps the given string s in Cyan | ||
// | ||
// Example: | ||
// println(color.InCyan("This is cyan")) | ||
// | ||
// println(color.InCyan("This is cyan")) | ||
func InCyan(s string) string { | ||
return Colorize(Cyan, s) | ||
} | ||
|
||
// InGray wraps the given string s in Gray | ||
// | ||
// Example: | ||
// println(color.InGray("This is gray")) | ||
// | ||
// println(color.InGray("This is gray")) | ||
func InGray(s string) string { | ||
return Colorize(Gray, s) | ||
} | ||
|
||
// InWhite wraps the given string s in White | ||
// | ||
// Example: | ||
// println(color.InWhite("This is white")) | ||
// | ||
// println(color.InWhite("This is white")) | ||
func InWhite(s string) string { | ||
return Colorize(White, s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would have preferred to call this function
Underline
, but that field is already taken by the variable so.. 😔