Code Monkey home page Code Monkey logo

Comments (6)

hexdigest avatar hexdigest commented on August 19, 2024

@sjames-iberis I didn't want to customize the header because giving two templates as an input to gowrap is kinda too much and may confuse people. Why do you need it?

from gowrap.

sjames-iberis avatar sjames-iberis commented on August 19, 2024

Customising header template is not a big issue. I only raised it because it would have provided a way to use the package name in the body (for example, by declaring a constant that the body could reference).

We need the package name in the body because we have a number packages which have an interface with the same name and method signature.

The package name is needed to identify which variant of the method is being invoked, for example in logging.

from gowrap.

hexdigest avatar hexdigest commented on August 19, 2024

@sjames-iberis Thanks for the explanation, I got your point. Exposing source package metadata and destination package metadata to the body template is not a problem and can be done easily, however I was thinking about passing any kind of vars to the body template from the command line in the form of key/value pairs. So that way, the decorator struct name/constructor name can be passed from the command line too. I think it will be a more generic solution. Does it make sence to you?

from gowrap.

sjames-iberis avatar sjames-iberis commented on August 19, 2024

Although I would still prefer it if all properties of the source interface were automatically available to the template, being able to define key/value pairs from the command line is definitely a useful feature, and we could leverage it make the package name available.

Thanks!

from gowrap.

hexdigest avatar hexdigest commented on August 19, 2024

@sjames-iberis please check new -v flags for setting .Vars from the command line.

I also changed all templates in the repo so now they aware of .Vars.DecoratorName which can be set via -v

This is an example from the templates_tests/interface_with_log.go:

gowrap gen -d . -i TestInterface -t ../templates/log -o interface_with_log.go -v DecoratorName=TestInterfaceWithLogger

You can pass multiple vars to the templates by using -v flag multiple times.

Please close the issue if this approach works for you.

from gowrap.

sjames-iberis avatar sjames-iberis commented on August 19, 2024

Confirmed that -v option can be used to define package name.

from gowrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.