-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags.go
31 lines (26 loc) · 950 Bytes
/
flags.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
package utils
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var verbose bool
func InitFlags(rootCmd *cobra.Command) {
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose output")
rootCmd.PersistentFlags().BoolP("version", "V", false, "Print the version")
rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
if cmd.Flags().Changed("version") {
fmt.Printf("Your CLI Tool Version %s\n", cmd.Version)
os.Exit(0)
}
}
rootCmd.Flags().String("branch", "main", "Specify the branch name (default is 'main')")
// projectName
rootCmd.Flags().String("projectName", "", "Specify the project name")
// beFramework
rootCmd.Flags().String("beFramework", "", "Specify the backend framework")
// feFramework
rootCmd.Flags().String("feFramework", "", "Specify the frontend framework")
// installDeps
rootCmd.Flags().String("installDeps", "", "If you want to install your dependencies")
}