goctl added
This commit is contained in:
15
tools/modelctl/model/configtemplategen/configtemplate.go
Normal file
15
tools/modelctl/model/configtemplategen/configtemplate.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package configgen
|
||||
|
||||
const configTemplate = `// TODO replace * to your real value
|
||||
{
|
||||
"WithCache": false,
|
||||
"Force": true,
|
||||
"Username": "***",
|
||||
"Password": "***",
|
||||
"Address": "**",
|
||||
"TableSchema":"*",
|
||||
"Tables": [
|
||||
"**"
|
||||
]
|
||||
}
|
||||
`
|
||||
29
tools/modelctl/model/configtemplategen/gen.go
Normal file
29
tools/modelctl/model/configtemplategen/gen.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package configgen
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"zero/tools/modelctl/model"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var (
|
||||
configFileName = "config.json"
|
||||
)
|
||||
|
||||
func ConfigCommand(_ *cli.Context) error {
|
||||
_, err := os.Stat(configFileName)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
file, err := os.OpenFile(configFileName, os.O_CREATE|os.O_WRONLY, model.ModeDirPerm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
file.WriteString(configTemplate)
|
||||
defer file.Close()
|
||||
fmt.Println("config json template generate done ... ")
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user