mirror of
				https://github.com/KevinMidboe/motdGO.git
				synced 2025-10-29 17:50:24 +00:00 
			
		
		
		
	fixed goreportcard stuff
This commit is contained in:
		
							
								
								
									
										2
									
								
								char.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								char.go
									
									
									
									
									
								
							| @@ -14,7 +14,7 @@ type asciiChar struct { | |||||||
| } | } | ||||||
|  |  | ||||||
| // Creates a new ascii character | // Creates a new ascii character | ||||||
| func NewAsciiChar(font *font, char rune) (*asciiChar, error) { | func newAsciiChar(font *font, char rune) (*asciiChar, error) { | ||||||
| 	// If not ascii, throw an error | 	// If not ascii, throw an error | ||||||
| 	if char < 0 || char > 127 { | 	if char < 0 || char > 127 { | ||||||
| 		return nil, errors.New("Not Ascii") | 		return nil, errors.New("Not Ascii") | ||||||
|   | |||||||
| @@ -1,12 +1,12 @@ | |||||||
| package main | package main | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"errors" |  | ||||||
| 	"flag" | 	"flag" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"github.com/fatih/color" | 	"github.com/fatih/color" | ||||||
| 	"github.com/probandula/figlet4go" | 	"github.com/probandula/figlet4go" | ||||||
| 	"log" | 	"log" | ||||||
|  | 	"os" | ||||||
| 	"strings" | 	"strings" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -22,10 +22,7 @@ func main() { | |||||||
| 	flag.Parse() | 	flag.Parse() | ||||||
|  |  | ||||||
| 	// Validate and log the error | 	// Validate and log the error | ||||||
| 	err := validate() | 	validate() | ||||||
| 	if err != nil { |  | ||||||
| 		log.Fatal(err) |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// Create objects | 	// Create objects | ||||||
| 	ascii := figlet4go.NewAsciiRender() | 	ascii := figlet4go.NewAsciiRender() | ||||||
| @@ -87,9 +84,9 @@ func getColorSlice(colorStr string) []color.Attribute { | |||||||
|  |  | ||||||
| // Validate if all required options are given | // Validate if all required options are given | ||||||
| // flag.Parse() must be called before this | // flag.Parse() must be called before this | ||||||
| func validate() error { | func validate() { | ||||||
| 	if *str == "" { | 	if *str == "" { | ||||||
| 		return errors.New("No string given") | 		flag.Usage() | ||||||
|  | 		os.Exit(1) | ||||||
| 	} | 	} | ||||||
| 	return nil |  | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								font.go
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								font.go
									
									
									
									
									
								
							| @@ -1,4 +1,5 @@ | |||||||
| package figlet4go | package figlet4go | ||||||
|  |  | ||||||
| // Explanation of the .flf file header | // Explanation of the .flf file header | ||||||
| // THE HEADER LINE | // THE HEADER LINE | ||||||
| // | // | ||||||
|   | |||||||
| @@ -66,7 +66,7 @@ func (fm *fontManager) getFont(fontName string) *font { | |||||||
| func (fm *fontManager) loadFontList(fontPath string) error { | func (fm *fontManager) loadFontList(fontPath string) error { | ||||||
| 	// Walk through the path | 	// Walk through the path | ||||||
| 	return filepath.Walk(fontPath, func(path string, info os.FileInfo, err error) error { | 	return filepath.Walk(fontPath, func(path string, info os.FileInfo, err error) error { | ||||||
| 		// Return an error if occured | 		// Return an error if occurred | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								render.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								render.go
									
									
									
									
									
								
							| @@ -13,7 +13,7 @@ type RenderOptions struct { | |||||||
| 	FontColor []color.Attribute | 	FontColor []color.Attribute | ||||||
| } | } | ||||||
|  |  | ||||||
| // Create new RenderOptions | // NewRenderOptions creates new RenderOptions | ||||||
| // Sets the default font name | // Sets the default font name | ||||||
| func NewRenderOptions() *RenderOptions { | func NewRenderOptions() *RenderOptions { | ||||||
| 	return &RenderOptions{ | 	return &RenderOptions{ | ||||||
| @@ -27,25 +27,25 @@ type AsciiRender struct { | |||||||
| 	fontMgr *fontManager | 	fontMgr *fontManager | ||||||
| } | } | ||||||
|  |  | ||||||
| // Create a new AsciiRender | // NewAsciiRender creates a new AsciiRender | ||||||
| func NewAsciiRender() *AsciiRender { | func NewAsciiRender() *AsciiRender { | ||||||
| 	return &AsciiRender{ | 	return &AsciiRender{ | ||||||
| 		fontMgr: newFontManager(), | 		fontMgr: newFontManager(), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| // Loading all *.flf font files recursively in a path | // LoadFont loads all *.flf font files recursively in a path | ||||||
| func (ar *AsciiRender) LoadFont(fontPath string) error { | func (ar *AsciiRender) LoadFont(fontPath string) error { | ||||||
| 	return ar.fontMgr.loadFontList(fontPath) | 	return ar.fontMgr.loadFontList(fontPath) | ||||||
| } | } | ||||||
|  |  | ||||||
| // Render a string with the default options | // Render renders a string with the default options | ||||||
| // Calls the RenderOpts method with a new RenderOptions object | // Calls the RenderOpts method with a new RenderOptions object | ||||||
| func (ar *AsciiRender) Render(str string) (string, error) { | func (ar *AsciiRender) Render(str string) (string, error) { | ||||||
| 	return ar.RenderOpts(str, NewRenderOptions()) | 	return ar.RenderOpts(str, NewRenderOptions()) | ||||||
| } | } | ||||||
|  |  | ||||||
| // Render a string with special RenderOptions | // RenderOpts renders a string with special RenderOptions | ||||||
| // Can be called from the user (if options wished) or the above Render method | // Can be called from the user (if options wished) or the above Render method | ||||||
| // Contains the whole rendering logic | // Contains the whole rendering logic | ||||||
| func (ar *AsciiRender) RenderOpts(str string, opt *RenderOptions) (string, error) { | func (ar *AsciiRender) RenderOpts(str string, opt *RenderOptions) (string, error) { | ||||||
| @@ -64,7 +64,7 @@ func (ar *AsciiRender) RenderOpts(str string, opt *RenderOptions) (string, error | |||||||
| 	// Foreach char create the ascii char | 	// Foreach char create the ascii char | ||||||
| 	for _, char := range str { | 	for _, char := range str { | ||||||
| 		// AsciiChar | 		// AsciiChar | ||||||
| 		asciiChar, err := NewAsciiChar(font, char) | 		asciiChar, err := newAsciiChar(font, char) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return "", err | 			return "", err | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user