package cmd import ( "fmt" "os" "github.com/spf13/cobra" ) // 定义根命令 var rootCmd = &cobra.Command{ Use: "app", Short: "数据导入/导出工具", } // Execute 函数用于执行根命令 func Execute() { if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) } } func init() { // 在初始化时添加导入和导出的子命令 rootCmd.AddCommand(exportCmd) rootCmd.AddCommand(importCmd) }