update flags

This commit is contained in:
Forest-L 2020-11-28 16:43:33 +08:00
parent 5607fee576
commit f3b47d9f57
4 changed files with 24 additions and 17 deletions

View File

@ -8,15 +8,9 @@ import (
"kubeye/pkg/validator"
)
func init() {
rootCmd.AddCommand(addCmd)
flag.Parse()
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
}
var addCmd = &cobra.Command{
Use: "install ntp",
Short: "install the ntp",
Use: "install npd",
Short: "install the npd",
Run: func(cmd *cobra.Command, args []string) {
err := validator.Add(cmd.Context())
if err != nil {
@ -24,3 +18,8 @@ var addCmd = &cobra.Command{
}
},
}
func init() {
rootCmd.AddCommand(addCmd)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
}

View File

@ -1,20 +1,15 @@
package cmd
import (
"flag"
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"kubeye/pkg/validator"
)
var config string
func init() {
rootCmd.AddCommand(auditCmd)
//flag.Parse()
//pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
auditCmd.Flags().StringVarP(&config, "filename", "f", "", "Customize best practice configuration")
}
var auditCmd = &cobra.Command{
Use: "audit",
Short: "audit the result",
@ -25,3 +20,9 @@ var auditCmd = &cobra.Command{
}
},
}
func init() {
rootCmd.AddCommand(auditCmd)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
auditCmd.Flags().StringVarP(&config, "filename", "f", "", "Customize best practice configuration")
}

View File

@ -21,9 +21,11 @@ import (
"os"
)
var Verbose bool
var rootCmd = &cobra.Command{
Use: "ke",
Short: "kubeye the cluster configuration",
Short: "Kubeye the cluster configuration",
}
func Execute() {
@ -32,3 +34,6 @@ func Execute() {
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().BoolVar(&Verbose, "debug", true, "Print detailed information")
}

View File

@ -15,7 +15,9 @@ limitations under the License.
*/
package main
import "kubeye/cmd"
import (
"kubeye/cmd"
)
func main() {
cmd.Execute()