From a878d5f9718854403e96d2d1443759ea5a458f9b Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Sun, 9 Jul 2023 14:45:03 -0400 Subject: [PATCH] Implementing simple cli for generating SVGs --- cmd/main.go | 31 +++++++++++++++++++++++++++++++ go.mod | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 cmd/main.go diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 0000000..4b0401f --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "flag" + "fmt" + "log" + + "github.com/therealfakemoot/go-badge" +) + +var ( + style, label, message, color, font string + size int +) + +func main() { + flag.StringVar(&style, "style", "flat", "label text") + flag.StringVar(&label, "label", "Build", "label text") + flag.StringVar(&message, "message", "failed", "message text") + flag.StringVar(&color, "color", badge.COLOR_CRITICAL, "label color, hexadecimal") + flag.StringVar(&font, "font", "Verdana.ttf", "font file, tff") + flag.IntVar(&size, "size", 10, "font size, pixels") + + flag.Parse() + + g, err := badge.NewGenerator(font, size) + if err != nil { + log.Fatalf("error instantiating generator: %s\n", err) + } + fmt.Println(string(g.GenerateFlat(label, message, color))) +} diff --git a/go.mod b/go.mod index b5f230d..013c4c5 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/essentialkaos/go-badge +module github.com/therealfakemoot/go-badge go 1.18