github.com/fatih/color
color.Blue("Prints %s in blue.", "text")
color.Red("We have red")
c := color.New(color.FgCyan).Add(color.Underline)
c.Println("Prints cyan text with an underline.")

import (
    "fmt"
    "github.com/spf13/cobra"
    "we7/php"
)

func main() {
var cmdPrint = &cobra.Command{
        Use:   "print",
        Short: "打印信息",
        Long: `打印描述`,
        Run: func(cmd *cobra.Command, args []string) {
            father := php.Choose("你喜欢吃什么?", map[string]string{
                "1":  "苹果",
                "2": "橘子",
                "3":   "西瓜",
            })
            php.Color(father,"blue")
            input:=php.Ask("请输入内容",nil)
            input1:=php.Confirm("请选择是否?")
            fmt.Println(input,input1)
        },
    }

    var cmdEcho = &cobra.Command{
        Use:   "echo",
        Short: "输出",
        Long: `输出描述`,
        Run: func(cmd *cobra.Command, args []string) {
            fmt.Println(args)
        },
    }
    version:="1.0.0"
    times:=php.Date("Y-m-d H:i:s")
    desc:="微擎帮助使用\n Update:"+times+"\n Author:Yoby \n Version:"+version
    var rootCmd = &cobra.Command{Use: "we7",Short:desc,Version:version}
    rootCmd.AddCommand(cmdPrint, cmdEcho)
    rootCmd.Execute()
}

progressbar https://github.com/schollz/progressbar //进度条

文档更新时间: 2021-12-23 20:02   作者:Yoby