diff --git a/src/main.go b/src/main.go index 4206a3ad..34707ea5 100644 --- a/src/main.go +++ b/src/main.go @@ -1,6 +1,8 @@ package main -import "github.com/jandedobbeleer/oh-my-posh/src/cli" +import ( + "github.com/jandedobbeleer/oh-my-posh/src/cli" +) func main() { cli.Execute() diff --git a/src/main_test.go b/src/main_test.go index 332971bf..c60fbe0b 100644 --- a/src/main_test.go +++ b/src/main_test.go @@ -10,7 +10,7 @@ import ( func BenchmarkInit(b *testing.B) { cmd := cli.RootCmd // needs to be a non-existing file as we panic otherwise - cmd.SetArgs([]string{"init", "fish", "--print", "--config", "err.omp.json"}) + cmd.SetArgs([]string{"init", "fish", "--print"}) out := bytes.NewBufferString("") cmd.SetOut(out) @@ -22,7 +22,7 @@ func BenchmarkInit(b *testing.B) { func BenchmarkPrimary(b *testing.B) { cmd := cli.RootCmd // needs to be a non-existing file as we panic otherwise - cmd.SetArgs([]string{"print", "primary", "--config", "err.omp.json", "--pwd", "/Users/jan/Code/oh-my-posh/src", "--shell", "fish"}) + cmd.SetArgs([]string{"print", "primary", "--pwd", "/Users/jan/Code/oh-my-posh/src", "--shell", "fish"}) out := bytes.NewBufferString("") cmd.SetOut(out) diff --git a/src/template/text.go b/src/template/text.go index 3557ecd9..fd4ab1f0 100644 --- a/src/template/text.go +++ b/src/template/text.go @@ -48,6 +48,8 @@ var ( } shell string + + tmplFunc = template.New("cache").Funcs(funcMap()) ) type Text struct { @@ -87,7 +89,7 @@ func (t *Text) Render() (string, error) { t.cleanTemplate() - tmpl, err := template.New(t.Template).Funcs(funcMap()).Parse(t.Template) + tmpl, err := tmplFunc.Parse(t.Template) if err != nil { t.Env.Error(err) return "", errors.New(InvalidTemplate) @@ -106,6 +108,7 @@ func (t *Text) Render() (string, error) { if len(msg) == 0 { return "", errors.New(IncorrectTemplate) } + return "", errors.New(msg["MSG"]) }