Split program into cmd + pkg

This commit is contained in:
Matt Baer 2021-01-19 08:09:12 -05:00
parent c73e844774
commit dbd85b75b5
2 changed files with 22 additions and 16 deletions

20
cmd/wfgraphic-cli/main.go Normal file
View File

@ -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))
}

View File

@ -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)