diff --git a/README.md b/README.txt similarity index 65% rename from README.md rename to README.txt index c8f9f9f..37ba01e 100644 --- a/README.md +++ b/README.txt @@ -1,7 +1,11 @@ -# ASCIITXT + _ ____ ____ ___ ___ _____ __ __ _____ + / \ / ___| / ___| |_ _| |_ _| |_ _| \ \/ / |_ _| + / _ \ \___ \ | | | | | | | | \ / | | + / ___ \ ___) | | |___ | | | | | | / \ | | + /_/ \_\ |____/ \____| |___| |___| |_| /_/\_\ |_| + -``` -Just a simple utilities for creating... +Just a simple utility for creating... _____ _____ __ __ _____ |_ _| | ____| \ \/ / |_ _| @@ -21,6 +25,7 @@ Just a simple utilities for creating... | | | _ | | | ___) | |_| |_| |_| |___| |____/ + The usage is pretty straight forward, on your Go file: import "github.com/aldy505/asciitxt" @@ -42,5 +47,7 @@ But, for now that's a long term plan. My current goal is to support most unicode letters and signs. -Licensed under MIT License. See the LICENSE file. -``` \ No newline at end of file +See Go Package documentation for more details: https://pkg.go.dev/github.com/aldy505/asciitxt + +Licensed under MIT License. +See the LICENSE file. diff --git a/asciitxt.go b/asciitxt.go index 22cb7d7..f95bfad 100644 --- a/asciitxt.go +++ b/asciitxt.go @@ -1,3 +1,4 @@ +// ASCIITXT is a simple utility for creating ascii texts. package asciitxt import ( @@ -7,20 +8,28 @@ import ( type Style int const ( - Standard Style = iota + 1 + StyleStandard Style = iota + 1 ) type Config struct { Style Style } +// Generates a multi-line ASCII string with the default style. +// As simple as that. func New(txt string) string { - return WithConfig(txt, Config{Style: Standard}) + return WithConfig(txt, Config{Style: StyleStandard}) } +// Generates a multi-line ASCII string from a defined Config. +// The config itself could be empty. It'll look for its' default value. +// But if you don't intend to put any config whatsoever, please use New(). +// +// Please note that this function will panic if the config.Style +// is invalid. Find the styles from the constants with Style prefix. func WithConfig(txt string, config Config) string { if config.Style == 0 { - config.Style = Standard + config.Style = StyleStandard } letters := strings.Split(txt, "") @@ -48,10 +57,11 @@ func WithConfig(txt string, config Config) string { return output } +// func getStyleLength(style Style) int { switch style { - case Standard: - return StandardLength + case StyleStandard: + return standardLength default: return 0 } @@ -59,9 +69,9 @@ func getStyleLength(style Style) int { func getStyleLetter(style Style, letter string) []string { switch style { - case Standard: + case StyleStandard: return getStandardLetter(letter) default: panic("invalid style was given") } -} \ No newline at end of file +} diff --git a/asciitxt_test.go b/asciitxt_test.go index 1a2634b..874ed1f 100644 --- a/asciitxt_test.go +++ b/asciitxt_test.go @@ -15,7 +15,7 @@ func TestNew(t *testing.T) { } func TestWithConfig(t *testing.T) { s := asciitxt.WithConfig("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789 _ the quick brown fox jumps over the lazy dog", asciitxt.Config{}) - + if s == "" { t.Error("should not be empty") } diff --git a/standard.go b/standard.go index 9d3fdf7..5ed8e91 100644 --- a/standard.go +++ b/standard.go @@ -1,6 +1,6 @@ package asciitxt -const StandardLength = 6 +const standardLength = 6 func getStandardLetter(letter string) []string { switch letter {