cli
软件包cli提供了一个框架,用于在Go中构建命令行应用程序,大部分参数解析和验证的负担都放在框架上而不是用户身上。
入门
以下示例演示了该软件包的基本用法。
简易申请
在这个简单的应用程序中,我们模仿标准UNIX cp命令的参数解析。 我们的应用程序要求用户指定一个或多个源文件,然后指定目标。 可以提供可选的递归标志。
package main
import (
"fmt"
"os"
"github.com/jawher/mow.cli"
)
func main () {
// create an app
app := cli . App ( "cp" , "Copy files around" )
// Here's what differentiates mow.cli from other CLI libraries:
// This line is not just for help message generation.
// It also validates the call to reject calls with less than 2 a
评论0
最新资源