-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd_root.go
More file actions
37 lines (31 loc) · 858 Bytes
/
cmd_root.go
File metadata and controls
37 lines (31 loc) · 858 Bytes
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
package cli
import (
"fmt"
"github.com/benchkram/cli-utils/base/app"
"github.com/spf13/cobra"
)
// rootCmd represents the base command when called without any subcommands
// we can attach subcommands to this command
var rootCmd = &cobra.Command{
Use: "our_app",
Short: "cli to start example server & client",
Long: "cli to start example server & client",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
readGlobalConfig()
},
Run: func(cmd *cobra.Command, args []string) {
err := runRootJob()
// On the most outside function we only log error
if err != nil {
fmt.Println(err)
}
},
}
// runRootJob is the actual job that is executed by the root command
func runRootJob() (err error) {
// Print global config
GlobalConfig.Print()
// Create new app instance
newApp := app.NewApplication()
return newApp.Start()
}