{"id":13573449,"url":"https://github.com/gookit/gcli","last_synced_at":"2025-05-15T08:07:02.814Z","repository":{"id":40416481,"uuid":"137190164","full_name":"gookit/gcli","owner":"gookit","description":"🖥 Go CLI application, tool library, running CLI commands, support console color, user interaction, progress display, data formatting display, generate bash/zsh completion add more features. Go的命令行应用，工具库，运行CLI命令，支持命令行色彩，用户交互，进度显示，数据格式化显示，生成bash/zsh命令补全脚本","archived":false,"fork":false,"pushed_at":"2025-04-15T05:41:03.000Z","size":6802,"stargazers_count":371,"open_issues_count":5,"forks_count":40,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-29T07:38:35.134Z","etag":null,"topics":["cli","cli-app","cli-application","cli-commands","cli-progress-bar","command-line","commands","console","console-application","go-cli","go-command-line","golang","gookit"],"latest_commit_sha":null,"homepage":"https://gookit.github.io/gcli/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gookit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-06-13T09:00:41.000Z","updated_at":"2025-04-16T03:09:26.000Z","dependencies_parsed_at":"2024-02-08T06:29:05.790Z","dependency_job_id":"00f5935c-77d4-4d67-9c97-94a0bdcad6b2","html_url":"https://github.com/gookit/gcli","commit_stats":{"total_commits":522,"total_committers":8,"mean_commits":65.25,"dds":0.1724137931034483,"last_synced_commit":"9fcbbec1d9877d6adbd7a996d7e763662e585e06"},"previous_names":["golangkit/cliapp","gookit/cliapp"],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gookit","download_url":"https://codeload.github.com/gookit/gcli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301431,"owners_count":22047904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cli-app","cli-application","cli-commands","cli-progress-bar","command-line","commands","console","console-application","go-cli","go-command-line","golang","gookit"],"created_at":"2024-08-01T15:00:35.873Z","updated_at":"2025-05-15T08:07:02.760Z","avatar_url":"https://github.com/gookit.png","language":"Go","readme":"# GCli \n\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/gookit/gcli?style=flat-square)\n[![Actions Status](https://github.com/gookit/gcli/workflows/action-tests/badge.svg)](https://github.com/gookit/gcli/actions)\n[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/gookit/gcli)](https://github.com/gookit/gcli)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4f071e6858fb4117b6c1376c9316d8ef)](https://www.codacy.com/gh/gookit/gcli/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=gookit/gcli\u0026amp;utm_campaign=Badge_Grade)\n[![Go Reference](https://pkg.go.dev/badge/github.com/gookit/goutil.svg)](https://pkg.go.dev/github.com/gookit/goutil)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/gcli)](https://goreportcard.com/report/github.com/gookit/gcli)\n[![Coverage Status](https://coveralls.io/repos/github/gookit/gcli/badge.svg?branch=master)](https://coveralls.io/github/gookit/gcli?branch=master)\n\nA simple and easy-to-use command-line application and tool library written in Golang.\nIncluding running commands, color styles, data display, progress display, interactive methods, etc.\n\n## [中文说明](README.zh-CN.md)\n\n中文说明请看 **[README.zh-CN](README.zh-CN.md)**\n\n## Screenshots\n\n![app-cmd-list](_examples/images/cmd-list.png)\n\n## Features\n\n- Rich in functions and easy to use\n- Support for adding multiple commands and supporting command **aliases**\n- Support binding command options from structure\n    - example `flag:\"name=int0;shorts=i;required=true;desc=int option message\"`\n- Support for adding multi-level commands, each level of command supports binding its own options\n- `option/flag` - support option binding `--long`, support for adding short options(`-s`)\n  - POSIX-style short flag combining (`-a -b` = `-ab`)\n  - Support setting `Required`, indicating a required option parameter\n  - Support setting `Validator`, which can customize the validation input parameters\n- `argument` - support binding argument to specify name\n  - Support `required`, optional, `array` settings\n  - It will be automatically detected and collected when the command is run.\n- `colorable` - supports rich color output. provide by [gookit/color](https://github.com/gookit/color)\n  - Supports html tab-style color rendering, compatible with Windows\n  - Built-in `info, error, success, danger` and other styles, can be used directly\n- `interact` Built-in user interaction methods: `ReadLine`, `Confirm`, `Select`, `MultiSelect` ...\n- `progress` Built-in progress display methods: `Txt`, `Bar`, `Loading`, `RoundTrip`, `DynamicText` ...\n- Automatically generate command help information and support color display\n- When the command entered is incorrect, a similar command will be prompted(including an alias prompt)\n- Supports generation of `zsh` and `bash` command completion script files\n- Supports a single command as a stand-alone application\n\n**Flag Options**:\n\n- Options start with `-` or `--`, and the first character must be a letter\n- Support long option. eg: `--long` `--long value`\n- Support short option. eg: `-s -a value`\n- Support define array option\n    - eg: `--tag php --tag go` will get `tag: [php, go]`\n\n**Flag Arguments**:\n\n- Support binding named argument\n- Support define array argument\n\n## GoDoc\n\n- [godoc](https://pkg.go.dev/github.com/gookit/gcli/v3)\n\n## Install\n\n```bash\ngo get github.com/gookit/gcli/v3\n```\n\n## Quick start\n\nan example for quick start:\n\n```go\npackage main\n\nimport (\n    \"github.com/gookit/gcli/v3\"\n    \"github.com/gookit/gcli/v3/_examples/cmd\"\n)\n\n// for test run: go build ./_examples/cliapp.go \u0026\u0026 ./cliapp\nfunc main() {\n    app := gcli.NewApp()\n    app.Version = \"1.0.3\"\n    app.Desc = \"this is my cli application\"\n    // app.SetVerbose(gcli.VerbDebug)\n\n    app.Add(cmd.Example)\n    app.Add(\u0026gcli.Command{\n        Name: \"demo\",\n        // allow color tag and {$cmd} will be replace to 'demo'\n        Desc: \"this is a description \u003cinfo\u003emessage\u003c/\u003e for {$cmd}\", \n        Subs: []*gcli.Command {\n            // ... allow add subcommands\n        },\n        Aliases: []string{\"dm\"},\n        Func: func (cmd *gcli.Command, args []string) error {\n            gcli.Print(\"hello, in the demo command\\n\")\n            return nil\n        },\n    })\n\n    // .... add more ...\n\n    app.Run(nil)\n}\n```\n\n## Binding flags\n\nflags binding and manage by builtin `gflag.go`, allow binding flag options and arguments.\n\n### Bind options\n\ngcli support multi method to binding flag options.\n\n#### Use flag methods\n\nAvailable methods:\n\n```go\nBoolOpt(p *bool, name, shorts string, defValue bool, desc string)\nBoolVar(p *bool, meta FlagMeta)\nFloat64Opt(p *float64, name, shorts string, defValue float64, desc string)\nFloat64Var(p *float64, meta FlagMeta)\nInt64Opt(p *int64, name, shorts string, defValue int64, desc string)\nInt64Var(p *int64, meta FlagMeta)\nIntOpt(p *int, name, shorts string, defValue int, desc string)\nIntVar(p *int, meta FlagMeta)\nStrOpt(p *string, name, shorts, defValue, desc string)\nStrVar(p *string, meta FlagMeta)\nUint64Opt(p *uint64, name, shorts string, defValue uint64, desc string)\nUint64Var(p *uint64, meta FlagMeta)\nUintOpt(p *uint, name, shorts string, defValue uint, desc string)\nUintVar(p *uint, meta FlagMeta)\nVar(p flag.Value, meta FlagMeta)\nVarOpt(p flag.Value, name, shorts, desc string)\n```\n\nUsage examples:\n\n```go\nvar id int\nvar b bool\nvar opt, dir string\nvar f1 float64\nvar names gcli.Strings\n\n// bind options\ncmd.IntOpt(\u0026id, \"id\", \"\", 2, \"the id option\")\ncmd.BoolOpt(\u0026b, \"bl\", \"b\", false, \"the bool option\")\n// notice `DIRECTORY` will replace to option value type\ncmd.StrOpt(\u0026dir, \"dir\", \"d\", \"\", \"the `DIRECTORY` option\")\n// setting option name and short-option name\ncmd.StrOpt(\u0026opt, \"opt\", \"o\", \"\", \"the option message\")\n// setting a special option var, it must implement the flag.Value interface\ncmd.VarOpt(\u0026names, \"names\", \"n\", \"the option message\")\n```\n\n#### Use struct tags\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/gookit/gcli/v3\"\n)\n\ntype userOpts struct {\n\tInt  int    `flag:\"name=int0;shorts=i;required=true;desc=int option message\"`\n\tBol  bool   `flag:\"name=bol;shorts=b;desc=bool option message\"`\n\tStr1 string `flag:\"name=str1;shorts=o,h;required=true;desc=str1 message\"`\n\t// use ptr\n\tStr2 *string `flag:\"name=str2;required=true;desc=str2 message\"`\n\t// custom type and implement flag.Value\n\tVerb0 gcli.VerbLevel `flag:\"name=verb0;shorts=V;desc=verb0 message\"`\n\t// use ptr\n\tVerb1 *gcli.VerbLevel `flag:\"name=verb1;desc=verb1 message\"`\n}\n\nfunc main() {\n\tastr := \"xyz\"\n\tverb := gcli.VerbWarn\n\n\tcmd := gcli.NewCommand(\"test\", \"desc\")\n\t// fs := gcli.NewFlags(\"test\")\n\t// err := fs.FromStruct(\u0026userOpts{\n\terr := cmd.FromStruct(\u0026userOpts{\n\t\tStr2:  \u0026astr,\n\t\tVerb1: \u0026verb,\n\t})\n\tfmt.Println(err)\n}\n```\n\n### Bind arguments\n\n**About arguments**:\n\n- Required argument cannot be defined after optional argument\n- Support binding array argument\n- The (array)argument of multiple values can only be defined at the end\n\nAvailable methods:\n\n```go\nAdd(arg Argument) *Argument\nAddArg(name, desc string, requiredAndArrayed ...bool) *Argument\nAddArgByRule(name, rule string) *Argument\nAddArgument(arg *Argument) *Argument\nBindArg(arg Argument) *Argument\n```\n\nUsage examples:\n\n```go\ncmd.AddArg(\"arg0\", \"the first argument, is required\", true)\ncmd.AddArg(\"arg1\", \"the second argument, is required\", true)\ncmd.AddArg(\"arg2\", \"the optional argument, is optional\")\ncmd.AddArg(\"arrArg\", \"the array argument, is array\", false, true)\n```\n\ncan also use `Arg()/BindArg()` add a gcli.Argument object:\n\n```go\ncmd.Arg(\"arg0\", gcli.Argument{\n\tName: \"ag0\",\n\tDesc: \"the first argument, is required\",\n\tRequire: true,\n})\ncmd.BindArg(\"arg2\", gcli.Argument{\n\tName: \"ag0\",\n\tDesc: \"the third argument, is is optional\",\n})\ncmd.BindArg(\"arrArg\", gcli.Argument{\n\tName: \"arrArg\",\n\tDesc: \"the third argument, is is array\",\n\tArrayed: true,\n})\n```\n\nuse `AddArgByRule`:\n\n```go\ncmd.AddArgByRule(\"arg2\", \"add an arg by string rule;required;23\")\n```\n\n## New application\n\n```go\napp := gcli.NewApp()\napp.Version = \"1.0.3\"\napp.Desc = \"this is my cli application\"\n// app.SetVerbose(gcli.VerbDebug)\n```\n\n## Add commands\n\n```go\napp.Add(cmd.Example)\napp.Add(\u0026gcli.Command{\n    Name: \"demo\",\n    // allow color tag and {$cmd} will be replace to 'demo'\n    Desc: \"this is a description \u003cinfo\u003emessage\u003c/\u003e for {$cmd}\", \n    Subs: []*gcli.Command {\n        // level1: sub commands...\n    \t{\n            Name:    \"remote\",\n            Desc:    \"remote command for git\",\n            Aliases: []string{\"rmt\"},\n            Func: func(c *gcli.Command, args []string) error {\n                dump.Println(c.Path())\n                return nil\n            },\n            Subs: []*gcli.Command{\n                // level2: sub commands...\n                // {}\n            }\n        },\n        // ... allow add subcommands\n    },\n    Aliases: []string{\"dm\"},\n    Func: func (cmd *gcli.Command, args []string) error {\n        gcli.Print(\"hello, in the demo command\\n\")\n        return nil\n    },\n})\n```\n\n## Run application\n\nBuild the example application as demo\n\n```bash\n$ go build ./_examples/cliapp                                                         \n```\n\n**Display version**\n\n```bash\n$ ./cliapp --version      \n# or use -V                                                 \n$ ./cliapp -V                                                     \n```\n\n![app-version](_examples/images/app-version.jpg)\n\n**Display app help**\n\n\u003e by `./cliapp` or `./cliapp -h` or `./cliapp --help`\n\nExamples:\n\n```bash\n./cliapp\n./cliapp -h # can also\n./cliapp --help # can also\n```\n\n![cmd-list](_examples/images/cmd-list.png)\n\n **Run command**\n\nFormat:\n\n```bash\n./cliapp COMMAND [--OPTION VALUE -S VALUE ...] [ARGUMENT0 ARGUMENT1 ...]\n./cliapp COMMAND [--OPTION VALUE -S VALUE ...] SUBCOMMAND [--OPTION ...] [ARGUMENT0 ARGUMENT1 ...]\n```\n\nRun example:\n\n```bash\n$ ./cliapp example -c some.txt -d ./dir --id 34 -n tom -n john val0 val1 val2 arrVal0 arrVal1 arrVal2\n```\n\nYou can see:\n\n![run-example](_examples/images/run-example.png)\n\n**Display command help**\n\n\u003e by `./cliapp example -h` or `./cliapp example --help`\n\n![cmd-help](_examples/images/cmd-help.png)\n\n**Error command tips**\n\n![command tips](_examples/images/err-cmd-tips.jpg)\n\n## Generate Auto Completion Scripts\n\n```go\nimport  \"github.com/gookit/gcli/v3/builtin\"\n\n    // ...\n    // add gen command(gen successful you can remove it)\n    app.Add(builtin.GenAutoComplete())\n\n```\n\nBuild and run command(_This command can be deleted after success._)：\n\n```bash\n$ go build ./_examples/cliapp.go \u0026\u0026 ./cliapp genac -h // display help\n$ go build ./_examples/cliapp.go \u0026\u0026 ./cliapp genac // run gen command\n```\n\nwill see:\n\n```text\nINFO: \n  {shell:zsh binName:cliapp output:auto-completion.zsh}\n\nNow, will write content to file auto-completion.zsh\nContinue? [yes|no](default yes): y\n\nOK, auto-complete file generate successful\n```\n\n\u003e After running, it will generate an `auto-completion.{zsh|bash}` file in the current directory,\n and the shell environment name is automatically obtained.\n Of course, you can specify it manually at runtime\n\nGenerated shell script file ref： \n\n- bash env [auto-completion.bash](resource/auto-completion.bash) \n- zsh env [auto-completion.zsh](resource/auto-completion.zsh)\n\nPreview: \n\n![auto-complete-tips](_examples/images/auto-complete-tips.jpg)\n\n## Write a command\n\ncommand allow setting fields:\n\n- `Name` the command name.\n- `Desc` the command description.\n- `Aliases` the command alias names.\n- `Config` the command config func, will call it on init.\n- `Subs` add subcommands, allow multi level subcommands\n- `Func` the command handle callback func\n- More, please see [godoc](https://pkg.go.dev/github.com/gookit/gcli/v3)\n\n### Quick create\n\n```go\nvar MyCmd = \u0026gcli.Command{\n    Name: \"demo\",\n    // allow color tag and {$cmd} will be replace to 'demo'\n    Desc: \"this is a description \u003cinfo\u003emessage\u003c/\u003e for command {$cmd}\", \n    Aliases: []string{\"dm\"},\n    Func: func (cmd *gcli.Command, args []string) error {\n        gcli.Print(\"hello, in the demo command\\n\")\n        return nil\n    },\n    // allow add multi level subcommands\n    Subs: []*gcli.Command{},\n}\n```\n\n### Write go file\n\n\u003e the source file at: [example.go](_examples/cmd/example.go)\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/gookit/color\"\n\t\"github.com/gookit/gcli/v3\"\n\t\"github.com/gookit/goutil/dump\"\n)\n\n// options for the command\nvar exampleOpts = struct {\n\tid  int\n\tc   string\n\tdir string\n\topt string\n\tnames gcli.Strings\n}{}\n\n// ExampleCommand command definition\nvar ExampleCommand = \u0026gcli.Command{\n\tName: \"example\",\n\tDesc: \"this is a description message\",\n\tAliases: []string{\"exp\", \"ex\"}, // 命令别名\n\t// {$binName} {$cmd} is help vars. '{$cmd}' will replace to 'example'\n\tExamples: `{$binName} {$cmd} --id 12 -c val ag0 ag1\n\u003ccyan\u003e{$fullCmd} --names tom --names john -n c\u003c/\u003e test use special option`,\n\tConfig: func(c *gcli.Command) {\n\t    // binding options\n        // ...\n        c.IntOpt(\u0026exampleOpts.id, \"id\", \"\", 2, \"the id option\")\n\t\tc.StrOpt(\u0026exampleOpts.c, \"config\", \"c\", \"value\", \"the config option\")\n\t\t// notice `DIRECTORY` will replace to option value type\n\t\tc.StrOpt(\u0026exampleOpts.dir, \"dir\", \"d\", \"\", \"the `DIRECTORY` option\")\n\t\t// 支持设置选项短名称\n\t\tc.StrOpt(\u0026exampleOpts.opt, \"opt\", \"o\", \"\", \"the option message\")\n\t\t// 支持绑定自定义变量, 但必须实现 flag.Value 接口\n\t\tc.VarOpt(\u0026exampleOpts.names, \"names\", \"n\", \"the option message\")\n\n      // binding arguments\n\t\tc.AddArg(\"arg0\", \"the first argument, is required\", true)\n\t\t// ...\n\t},\n\tFunc:  exampleExecute,\n}\n\n// 命令执行主逻辑代码\n// example run:\n// \tgo run ./_examples/cliapp.go ex -c some.txt -d ./dir --id 34 -n tom -n john val0 val1 val2 arrVal0 arrVal1 arrVal2\nfunc exampleExecute(c *gcli.Command, args []string) error {\n\tcolor.Infoln(\"hello, in example command\")\n\n\tif exampleOpts.showErr {\n\t\treturn c.NewErrf(\"OO, An error has occurred!!\")\n\t}\n\n\tmagentaln := color.Magenta.Println\n\n\tcolor.Cyanln(\"All Aptions:\")\n\t// fmt.Printf(\"%+v\\n\", exampleOpts)\n\tdump.V(exampleOpts)\n\n\tcolor.Cyanln(\"Remain Args:\")\n\t// fmt.Printf(\"%v\\n\", args)\n\tdump.P(args)\n\n\tmagentaln(\"Get arg by name:\")\n\tarr := c.Arg(\"arg0\")\n\tfmt.Printf(\"named arg '%s', value: %#v\\n\", arr.Name, arr.Value)\n\n\tmagentaln(\"All named args:\")\n\tfor _, arg := range c.Args() {\n\t\tfmt.Printf(\"- named arg '%s': %+v\\n\", arg.Name, arg.Value)\n\t}\n\n\treturn nil\n}\n```\n\n- display the command help：\n\n```bash\ngo build ./_examples/cliapp.go \u0026\u0026 ./cliapp example -h\n```\n\n![cmd-help](_examples/images/cmd-help.png)\n\n## Progress display\n\nPackage progress provide terminal progress bar display.\n\nSuch as: `Txt`, `Bar`, `Loading`, `RoundTrip`, `DynamicText` ...\n \n- `progress.Bar` progress bar\n\nDemo: `./cliapp prog bar`\n\n![prog-bar](_examples/images/progress/prog-bar.svg)\n\n- `progress.Txt` text progress bar\n\nDemo: `./cliapp prog txt`\n\n![prog-bar](_examples/images/progress/prog-txt.svg)\n\n- `progress.LoadBar` pending/loading progress bar\n\n![prog-demo](_examples/images/progress/prog-spinner.jpg)\n\n- `progress.Counter` counter \n- `progress.RoundTrip` round trip progress bar\n\n```text\n[===     ] -\u003e [    === ] -\u003e [ ===    ]\n```\n\n![prog-demo](_examples/images/progress/prog-rt.jpg)\n\n- `progress.DynamicText` dynamic text message\n\nExamples:\n\n```go\npackage main\n\nimport (\n\t\"time\"\n\n\t\"github.com/gookit/gcli/v3/progress\"\n)\n\nfunc main()  {\n\tspeed := 100\n\tmaxSteps := 110\n\tp := progress.Bar(maxSteps)\n\tp.Start()\n\n\tfor i := 0; i \u003c maxSteps; i++ {\n\t\ttime.Sleep(time.Duration(speed) * time.Millisecond)\n\t\tp.Advance()\n\t}\n\n\tp.Finish()\n}\n```\n\n\u003e more demos please see [progress_demo.go](_examples/cmd/progress_demo.go)\n\nrun demos:\n\n```bash\ngo run ./_examples/cliapp.go prog txt\ngo run ./_examples/cliapp.go prog bar\ngo run ./_examples/cliapp.go prog roundTrip\n```\n\n![prog-other](_examples/images/progress/prog-other.jpg)\n\n## Interactive methods\n   \nconsole interactive methods\n\n- `interact.ReadInput`\n- `interact.ReadLine`\n- `interact.ReadFirst`\n- `interact.Confirm`\n- `interact.Select/Choice`\n- `interact.MultiSelect/Checkbox`\n- `interact.Question/Ask`\n- `interact.ReadPassword`\n\nExamples:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/gookit/gcli/v3/interact\"\n)\n\nfunc main() {\n\tusername, _ := interact.ReadLine(\"Your name?\")\n\tpassword := interact.ReadPassword(\"Your password?\")\n\t\n\tok := interact.Confirm(\"ensure continue?\")\n\tif !ok {\n\t\t// do something...\n\t}\n    \n\tfmt.Printf(\"username: %s, password: %s\\n\", username, password)\n}\n```\n\n### Read Input\n\nread user input message\n\n```go\nans, _ := interact.ReadLine(\"Your name? \")\n\nif ans != \"\" {\n    color.Println(\"Your input: \", ans)\n} else {\n    color.Cyan.Println(\"No input!\")\n}\n```\n\n![interact-read](_examples/images/interact/read.jpg)\n\n### Select/Choice\n\n```go\nans := interact.SelectOne(\n    \"Your city name(use array)?\",\n    []string{\"chengdu\", \"beijing\", \"shanghai\"},\n    \"\",\n)\ncolor.Comment.Println(\"your select is: \", ans)\n```\n\n![interact-select](_examples/images/interact/select.jpg)\n\n### Multi Select/Checkbox\n\n```go\nans := interact.MultiSelect(\n    \"Your city name(use array)?\",\n    []string{\"chengdu\", \"beijing\", \"shanghai\"},\n    nil,\n)\ncolor.Comment.Println(\"your select is: \", ans)\n```\n\n![interact-select](_examples/images/interact/m-select.jpg)\n\n### Confirm Message\n\n```go\nif interact.Confirm(\"Ensure continue\") {\n    fmt.Println(emoji.Render(\":smile: Confirmed\"))\n} else {\n    color.Warn.Println(\"Unconfirmed\")\n}\n```\n\n![interact-confirm](_examples/images/interact/confirm.jpg)\n\n### Read Password\n\n```go\npwd := interact.ReadPassword()\n\ncolor.Comment.Println(\"your input password is: \", pwd)\n```\n\n![interact-passwd](_examples/images/interact/passwd.jpg)\n\n## CLI Color\n\n\u003e **Terminal color use [gookit/color](https://github.com/gookit/color)** Support windows `cmd.exe` `powerShell`\n\n- Color output display\n\n![colored-demo](_examples/images/color/color-demo.jpg)\n\n### Color usage\n\n```go\npackage main\n\nimport (\n    \"github.com/gookit/color\"\n)\n\nfunc main() {\n\t// simple usage\n\tcolor.Cyan.Printf(\"Simple to use %s\\n\", \"color\")\n\n\t// internal theme/style:\n\tcolor.Info.Tips(\"message\")\n\tcolor.Info.Prompt(\"message\")\n\tcolor.Warn.Println(\"message\")\n\tcolor.Error.Println(\"message\")\n\t\n\t// custom color\n\tcolor.New(color.FgWhite, color.BgBlack).Println(\"custom color style\")\n\n\t// can also:\n\tcolor.Style{color.FgCyan, color.OpBold}.Println(\"custom color style\")\n\t\n\t// use defined color tag\n\tcolor.Print(\"use color tag: \u003csuc\u003ehe\u003c/\u003e\u003ccomment\u003ello\u003c/\u003e, \u003ccyan\u003ewel\u003c/\u003e\u003cred\u003ecome\u003c/\u003e\\n\")\n\n\t// use custom color tag\n\tcolor.Print(\"custom color tag: \u003cfg=yellow;bg=black;op=underscore;\u003ehello, welcome\u003c/\u003e\\n\")\n\n\t// set a style tag\n\tcolor.Tag(\"info\").Println(\"info style text\")\n\n\t// prompt message\n\tcolor.Info.Prompt(\"prompt style message\")\n\tcolor.Warn.Prompt(\"prompt style message\")\n\n\t// tips message\n\tcolor.Info.Tips(\"tips style message\")\n\tcolor.Warn.Tips(\"tips style message\")\n}\n```\n\n\u003e **For more information on the use of color libraries, please visit [gookit/color](https://github.com/gookit/color)**\n\n## Gookit packages\n\n- [gookit/ini](https://github.com/gookit/ini) Go config management, use INI files\n- [gookit/rux](https://github.com/gookit/rux) Simple and fast request router for golang HTTP \n- [gookit/gcli](https://github.com/gookit/gcli) build CLI application, tool library, running CLI commands\n- [gookit/event](https://github.com/gookit/event) Lightweight event manager and dispatcher implements by Go\n- [gookit/cache](https://github.com/gookit/cache) Generic cache use and cache manager for golang. support File, Memory, Redis, Memcached.\n- [gookit/config](https://github.com/gookit/config) Go config management. support JSON, YAML, TOML, INI, HCL, ENV and Flags\n- [gookit/color](https://github.com/gookit/color) A command-line color library with true color support, universal API methods and Windows support\n- [gookit/filter](https://github.com/gookit/filter) Provide filtering, sanitizing, and conversion of golang data\n- [gookit/validate](https://github.com/gookit/validate) Use for data validation and filtering. support Map, Struct, Form data\n- [gookit/goutil](https://github.com/gookit/goutil) Some utils for the Go: string, array/slice, map, format, cli, env, filesystem, test and more\n- More please see https://github.com/gookit\n\n## See also\n\n- `inhere/console` https://github/inhere/php-console\n- `issue9/term` https://github.com/issue9/term\n- `beego/bee` https://github.com/beego/bee\n- [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code)\n\n## License\n\nMIT\n","funding_links":[],"categories":["Programming","CLI frameworks","Go"],"sub_categories":["Golang"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgookit%2Fgcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgookit%2Fgcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgookit%2Fgcli/lists"}