kevinconway / wrapgen

Interface wrapper generator for Go
Apache License 2.0
26 stars 9 forks source link

The left and right flags are flipped #4

Closed drewwells closed 6 years ago

drewwells commented 6 years ago

Using the example in the readme.md

-> % wrapgen -t "wrapgen.tmpl" -p "..." -r '}}' -l '{{'
template: wrapgen:5: unexpected unterminated quoted string in command
-> % wrapgen -t "wrapgen.tmpl" -p "..." -r '{{' -l '}}'
...output successful...
drewwells commented 6 years ago

Here's the diff to fix it

diff --git a/main.go b/main.go
index 26fd520..d6528d6 100644
--- a/main.go
+++ b/main.go
@@ -19,7 +19,7 @@ type pkgWrapper struct {
 }

 func render(templateString string, sourcePath string, pkg *wrapgen.Package, r string, l string) (string, error) {
-       var t, e = template.New("wrapgen").Funcs(sprig.TxtFuncMap()).Delims(r, l).Parse(templateString)
+       var t, e = template.New("wrapgen").Funcs(sprig.TxtFuncMap()).Delims(l, r).Parse(templateString)
        if e != nil {
                return "", e
        }
kevinconway commented 6 years ago

Wow! Thanks for catching that and pointing it out. While I was in there I noticed the default options for the flags were also swapped which is why the sample templates worked.

I merged a patch which corrects both of those problems (https://github.com/kevinconway/wrapgen/pull/5). I appreciate you taking the time to try out the tool and letting me know that something was off.