-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
91 lines (68 loc) · 2.63 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package init
import (
"github.com/macinnir/dvc/core/lib"
"go.uber.org/zap"
)
const CommandName = "init"
// Init creates a default dvc.toml file in the CWD
func Cmd(logger *zap.Logger, config *lib.Config, args []string) error {
return nil
// var e error
// if _, e = os.Stat("./dvc.toml"); os.IsNotExist(e) {
// reader := bufio.NewReader(os.Stdin)
// // https://tutorialedge.net/golang/reading-console-input-golang/
// // BasePackage
// fmt.Print("> Base Package:")
// basePackage, _ := reader.ReadString('\n')
// basePackage = strings.Replace(basePackage, "\n", "", -1)
// fmt.Print("> Base directory (leave blank for current):")
// baseDir, _ := reader.ReadString('\n')
// baseDir = strings.Replace(baseDir, "\n", "", -1)
// // Host
// fmt.Print("> Database Host:")
// host, _ := reader.ReadString('\n')
// host = strings.Replace(host, "\n", "", -1)
// // databaseName
// fmt.Print("> Database Name:")
// databaseName, _ := reader.ReadString('\n')
// databaseName = strings.Replace(databaseName, "\n", "", -1)
// // databaseUser
// fmt.Print("> Database User:")
// databaseUser, _ := reader.ReadString('\n')
// databaseUser = strings.Replace(databaseUser, "\n", "", -1)
// // databasePass
// fmt.Print("> Database Password:")
// databasePass, _ := reader.ReadString('\n')
// databasePass = strings.Replace(databasePass, "\n", "", -1)
// content := "databaseType = \"mysql\"\nbasePackage = \"" + basePackage + "\"\n\nenums = []\n\n"
// content += "[connection]\nhost = \"" + host + "\"\ndatabaseName = \"" + databaseName + "\"\nusername = \"" + databaseUser + "\"\npassword = \"" + databasePass + "\"\n\n"
// packages := []string{
// "repos",
// "models",
// "typescript",
// "services",
// "dal",
// "definitions",
// }
// content += "[packages]\n"
// for _, p := range packages {
// if p == "typescript" {
// continue
// }
// content += fmt.Sprintf("%s = \"%s\"\n", p, path.Join(basePackage, p))
// }
// // content += "[packages]\ncache = \"myPackage/cache\"\nmodels = \"myPackage/models\"\nschema = \"myPackage/schema\"\nrepos = \"myPackage/repos\"\n\n"
// content += "[dirs]\n"
// for _, p := range packages {
// if baseDir != "" {
// content += fmt.Sprintf("%s = \"%s\"\n", p, path.Join(baseDir, p))
// } else {
// content += fmt.Sprintf("%s = \"%s\"\n", p, p)
// }
// }
// // content += "[dirs]\nrepos = \"repos\"\ncache = \"cache\"\nmodels = \"models\"\nschema = \"schema\"\ntypescript = \"ts\""
// ioutil.WriteFile("./dvc.toml", []byte(content), 0644)
// } else {
// fmt.Println("dvc.toml already exists in this directory")
// }
}