/
root.go
48 lines (41 loc) · 1.12 KB
/
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
41
42
43
44
45
46
47
48
package cmd
import (
internal "github.com/mdelapenya/lpn/internal"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var verbose bool
var rootCmd = &cobra.Command{
Use: "lpn",
Short: "lpn (Liferay Portal Nook) makes it easier to run Liferay Portal's Docker images.",
Long: `A Fast and Flexible CLI for managing Liferay Portal's Docker images
built with ❤️ by mdelapenya and friends in Go.`,
Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here
enableDebugLevel()
},
}
func addVerboseFlag(c *cobra.Command) {
if c.Flag("verbose") == nil {
c.PersistentFlags().BoolVarP(&verbose, "verbose", "V", false, "Runs command with Debug log level")
}
}
func enableDebugLevel() {
if verbose {
internal.ConfigureLogger("DEBUG")
}
log.Debug("Debug logger activated")
}
// Execute execute root command
func Execute() {
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}
// SubCommandInfo Shows a message for subcommands
func SubCommandInfo() {
// delegate to subcommands
log.Warn(
"Please run this command adding 'ce', 'commerce', 'dxp', 'nightly' or 'release' " +
"subcommands.")
}