This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.go
70 lines (56 loc) · 1.44 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
68
69
70
package main
import (
"os"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"gopkg.in/AlecAivazis/survey.v1"
. "github.com/fionera/TeamDriveManager/cmd"
_ "github.com/fionera/TeamDriveManager/cmd/all"
"github.com/fionera/TeamDriveManager/config"
"github.com/fionera/TeamDriveManager/setup"
)
// Version - defined default version if it's not passed through flags during build
var Version string = "master"
func main() {
app := cli.NewApp()
app.Name = "TeamDriveManager"
app.Version = Version
app.Author = "fionera"
app.Email = "teamdrive-manager@fionera.de"
app.Usage = ""
app.Flags = GlobalFlags
app.Commands = Commands
app.CommandNotFound = CommandNotFound
app.Before = func(context *cli.Context) error {
config.LoadConfig()
if config.App.AppConfig.ServiceAccountFile == "" || config.App.AppConfig.Domain == "" {
cont := false
prompt := &survey.Confirm{
Message: "It seems TeamDriveManager isn't configured correctly. Start Setup?",
}
err := survey.AskOne(prompt, &cont, nil)
if err != nil {
return err
}
if !cont {
logrus.Info("Exiting.")
os.Exit(1)
}
setup.Setup()
}
if context.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
return nil
}
app.After = func(context *cli.Context) error {
if config.App.AppConfig.ServiceAccountFile != "" {
config.SaveConfig(config.App.AppConfig)
}
return nil
}
err := app.Run(os.Args)
if err != nil {
logrus.Panic(err)
}
}