-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathroot.go
40 lines (36 loc) · 894 Bytes
/
root.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
package cmd
import (
parse "github.com/gopinath-langote/1buildgo/cmd/config"
"github.com/gopinath-langote/1buildgo/cmd/exec"
"github.com/gopinath-langote/1buildgo/cmd/utils"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "1build",
Version: "1.1.2",
Short: "Frictionless way of managing project-specific commands",
Args: cobra.MinimumNArgs(0),
PreRun: func(cmd *cobra.Command, args []string) {
_, err := parse.LoadOneBuildConfiguration()
if err != nil {
utils.PrintErr(err)
utils.ExitError()
}
},
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
listCmd.Run(cmd, args)
} else {
exec.ExecuteCommandAndExit(args...)
}
},
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
utils.PrintErr(err)
utils.ExitError()
}
}
func init() {
rootCmd.SetHelpCommand(&cobra.Command{Use: "no-help", Hidden: true})
}