41 lines
815 B
Go
41 lines
815 B
Go
|
package cmd
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/urfave/cli/v2"
|
||
|
"html/template"
|
||
|
"ledo/app/modules/context"
|
||
|
"ledo/app/modules/interact"
|
||
|
"ledo/app/templates"
|
||
|
"log"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
var CmdInit = cli.Command{
|
||
|
Name: "init",
|
||
|
Aliases: []string{"i"},
|
||
|
Category: catSetup,
|
||
|
Usage: "Init ledo in project",
|
||
|
Description: `Initialize LeadDocker in current project`,
|
||
|
Action: runInitLedo,
|
||
|
}
|
||
|
|
||
|
func runInitLedo(cmd *cli.Context) error {
|
||
|
config, _ := context.LoadConfigFile()
|
||
|
data, err := interact.InitLedoProject(config.Docker)
|
||
|
tpl, err := template.New("tpl").Parse(templates.LedoConfigurationFileTemplate)
|
||
|
if err != nil {
|
||
|
log.Fatalln(err)
|
||
|
}
|
||
|
err = tpl.Execute(os.Stdout, data)
|
||
|
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
advRun := interact.InitAdvancedConfigurationAsk()
|
||
|
fmt.Printf("%v", advRun)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
|