From dbd85b75b5c7fb3caef5bc8fba8082fba37e8454 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 19 Jan 2021 08:09:12 -0500 Subject: [PATCH] Split program into cmd + pkg --- cmd/wfgraphic-cli/main.go | 20 ++++++++++++++++++++ main.go => textpic.go | 18 ++---------------- 2 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 cmd/wfgraphic-cli/main.go rename main.go => textpic.go (91%) diff --git a/cmd/wfgraphic-cli/main.go b/cmd/wfgraphic-cli/main.go new file mode 100644 index 0000000..74ff4a6 --- /dev/null +++ b/cmd/wfgraphic-cli/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "os" + "time" + + "github.com/writeas/text-pic" + "github.com/writeas/web-core/log" +) + +func main() { + log.Info("Starting...") + start := time.Now() + err := textpic.Run() + if err != nil { + log.Error("%s", err) + os.Exit(1) + } + log.Info("Completed in %s", time.Since(start)) +} diff --git a/main.go b/textpic.go similarity index 91% rename from main.go rename to textpic.go index f76f2c2..2938065 100644 --- a/main.go +++ b/textpic.go @@ -1,27 +1,13 @@ -package main +package textpic import ( "fmt" "image/color" - "os" "path/filepath" - "time" "github.com/fogleman/gg" - "github.com/writeas/web-core/log" ) -func main() { - log.Info("Starting...") - start := time.Now() - err := run() - if err != nil { - log.Error("%s", err) - os.Exit(1) - } - log.Info("Completed in %s", time.Since(start)) -} - func loadFont(dc *gg.Context, bold bool, points float64) error { fontLoraBoldPath := filepath.Join("fonts", "Lora-Bold.ttf") fontLoraPath := filepath.Join("fonts", "Lora-Regular.ttf") @@ -37,7 +23,7 @@ func loadFont(dc *gg.Context, bold bool, points float64) error { return nil } -func run() error { +func Run() error { w := 900 h := 900 wf := float64(w)