diff --git a/cmd/commit0.go b/cmd/commit0.go index f54cf238b..8d74067ef 100644 --- a/cmd/commit0.go +++ b/cmd/commit0.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "github.com/commitdev/commit0/templator" + "github.com/gobuffalo/packr/v2" "github.com/spf13/cobra" "os" ) @@ -17,8 +18,13 @@ var rootCmd = &cobra.Command{ }, } -func Execute(templates *templator.Templator) { - Templator = templates +func Init() { + templates := packr.New("templates", "../templates") + Templator = templator.NewTemplator(templates) +} + +func Execute() { + Init() if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) diff --git a/main.go b/main.go index 825c5f7fb..7c249737b 100644 --- a/main.go +++ b/main.go @@ -2,12 +2,8 @@ package main import ( "github.com/commitdev/commit0/cmd" - "github.com/commitdev/commit0/templator" - "github.com/gobuffalo/packr/v2" ) func main() { - templates := packr.New("templates", "./templates") - templator := templator.NewTemplator(templates) - cmd.Execute(templator) + cmd.Execute() }