Giter VIP home page Giter VIP logo

Comments (6)

markbates avatar markbates commented on August 22, 2024

A PR would definitely be welcome.

from pop.

vdlbk avatar vdlbk commented on August 22, 2024

Ok great, I will try to see how it works and if I have enough time maybe work on it.

Any infos or guidelines are welcome !

from pop.

markbates avatar markbates commented on August 22, 2024

Off the top of my head I would suggestion using the fizz package to build the sql for the forest platform, and then dump that into the generated sql file.

from pop.

vdlbk avatar vdlbk commented on August 22, 2024

Indeed, using the fizz package works pretty well, but I need to use a *pop.Connection in order to retrieve the correct Dialect and generate the good sql file depending the environment.

I saw that there is a function getConn() in the github.com/gobuffalo/pop/soda/cmd package.
So far, I passed the function as an argument into a constructor which return the ModelCmd.

Here's a snippet of this :

package generate 

...
type getConnection func() *pop.Connection

func NewModelCmd(f getConnection) *cobra.Command {
	connection = f()
	return ModelCmd
}

But it seems very ugly to do so, maybe any of you has an idea about how could I do this ?

from pop.

markbates avatar markbates commented on August 22, 2024

I definitely wouldn't do that. :)

All the getConn function does is check if a connection is in the map. I wouldn't go that far. You can do something as simple as:

eee, err := cmd.Flags().GetString("env")
if err != nil {
	return errors.WithStack(err)
}
db, err := pop.Connect(eee)

This is a persistent flag on the root command for the environment string. you can get access to that inside whatever sub-command you're in.

from pop.

vdlbk avatar vdlbk commented on August 22, 2024

I close this issue since the PR #63 was merged

from pop.

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.