-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
67 lines (58 loc) · 1.57 KB
/
main.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
package main
import (
"github.com/nanopack/butter/api"
"github.com/nanopack/butter/auth"
"github.com/nanopack/butter/config"
"github.com/nanopack/butter/deploy"
"github.com/nanopack/butter/repo"
"github.com/nanopack/butter/server"
"github.com/spf13/cobra"
)
func main() {
server := true
configFile := ""
command := cobra.Command{
Use: "butter",
Short: "butter makes the breads silky smooth",
Long: `Butter is a solid dairy product made by churning fresh or fermented cream or milk, to separate the butterfat from the buttermilk. It is generally used as a spread on plain or toasted bread products and a condiment on cooked vegetables, as well as in cooking, such as baking, sauce making, and pan frying. Butter consists of butterfat, milk proteins and water.`,
Run: func(ccmd *cobra.Command, args []string) {
if !server {
ccmd.HelpFunc()(ccmd, args)
return
}
if configFile != "" {
config.Parse(configFile)
}
serverStart()
},
}
config.AddFlags(&command)
command.Flags().BoolVarP(&server, "server", "s", false, "Run as server")
command.Flags().StringVarP(&configFile, "configFile", "", "", "[server] config file location")
// when we create a cli i will add it here
// cli.AddCli(command)
command.Execute()
}
func serverStart() {
err := deploy.Setup()
if err != nil {
panic(err)
}
err = repo.Setup()
if err != nil {
panic(err)
}
err = auth.Setup()
if err != nil {
panic(err)
}
sshServer, err := server.StartServer()
if err != nil {
panic(err)
}
defer sshServer.Close()
err = api.Start()
if err != nil {
panic(err)
}
}