feat: Replace cli to cobra (#1855)
* Replace cli * Replace cli * Replace cli * Format code * Add compare case * Add compare case * Add compare case * Support go style flag * Support go style flag * Add test case
This commit is contained in:
46
tools/goctl/env/cmd.go
vendored
Normal file
46
tools/goctl/env/cmd.go
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
package env
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
sliceVarWriteValue []string
|
||||
boolVarForce bool
|
||||
boolVarVerbose bool
|
||||
boolVarInstall bool
|
||||
|
||||
// Cmd describes a env command.
|
||||
Cmd = &cobra.Command{
|
||||
Use: "env",
|
||||
Short: "Check or edit goctl environment",
|
||||
RunE: write,
|
||||
}
|
||||
installCmd = &cobra.Command{
|
||||
Use: "install",
|
||||
Short: "Goctl env installation",
|
||||
RunE: install,
|
||||
}
|
||||
checkCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "Detect goctl env and dependency tools",
|
||||
RunE: check,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
// The root command flags
|
||||
Cmd.Flags().StringSliceVarP(&sliceVarWriteValue,
|
||||
"write", "w", nil, "Edit goctl environment")
|
||||
Cmd.PersistentFlags().BoolVarP(&boolVarForce,
|
||||
"force", "f", false,
|
||||
"Silent installation of non-existent dependencies")
|
||||
Cmd.PersistentFlags().BoolVarP(&boolVarVerbose,
|
||||
"verbose", "v", false, "Enable log output")
|
||||
|
||||
// The sub-command flags
|
||||
checkCmd.Flags().BoolVarP(&boolVarInstall, "install", "i",
|
||||
false, "Install dependencies if not found")
|
||||
|
||||
// Add sub-command
|
||||
Cmd.AddCommand(installCmd)
|
||||
Cmd.AddCommand(checkCmd)
|
||||
}
|
||||
Reference in New Issue
Block a user