cli README

The project's README from github.com/urfave/cli. As one markdown file: README.md.

Welcome to urfave/cli

Go Reference Go Report Card codecov Tests status

urfave/cli is a declarative, simple, fast, and fun package for building command line tools in Go featuring:

Documentation

See the hosted documentation website at https://cli.urfave.org. Contents of this website are built from the ./docs directory.

Support

Check the Q&A discussions. If you don't find answer to your question, create a new discussion.

If you found a bug or have a feature request, create a new issue.

Please keep in mind that this project is run by unpaid volunteers.

License

See LICENSE.

cli (urfave/cli)

Searching Database…

24.3K ·GitHub
这是什么东西?urfave/cli 是一个用于构建命令行工具的 Go 包。你用 Go 声明命令、子命令和标志,它会帮你处理参数解析、帮助系统和 shell 自动补全。
所以它是一个要导入到我自己 Go 项目里的库,不是一个下载下来就能运行的程序?没错——它是一个 Go 包,会成为你正在编写的命令行工具的一部分。它定义你的应用如何解析标志、如何组织子命令以及如何输出帮助信息;单独拿来它什么都不做。
怎么把它加到项目里?在你的 Go module 里运行 go get github.com/urfave/cli/v3,然后在代码里定义你的命令和标志即可。官方文档网站上有构建第一个应用的完整教程。
引入它会不会拖进来一堆依赖?不会。它唯一的依赖就是 Go 标准库,所以加到项目里非常轻量。
我可以定义哪些类型的标志?支持简单类型、简单类型的切片、时间、时长等多种类型的标志。还支持组合短标志,比如用户可以输入 -abc 来代替 -a -b -c。
我工具的配置项除了命令行,还能从别的地方读取吗?可以。配置值可以从环境变量、纯文本文件和结构化文件格式中读取,其中结构化格式由独立的 urfave/cli-altsrc 模块处理(支持 JSON、TOML 和 YAML)。
我的工具能开箱即用地为用户提供 shell 自动补全吗?能——这个包可以为 bash、zsh、fish 和 powershell 生成动态的 shell 补全。
我需要自己为命令编写 man 手册页或 Markdown 文档吗?不需要——urfave/cli 可以通过 urfave/cli-docs 模块生成 man 和 Markdown 格式的文档。
What are similar projects?cheat, inshellisense, yq, terminalizer, oh-my-posh, gvm, ipatool, viper
Creator
urfave
Size
12.5 MB
Stars
24.3K
Age
13y
Commits · 90 Days