clop v0.0.11 版本发布,Golang 实现的命令行解析器
项目地址
https://gitee.com/guonaihong/clop
https://github.com/guonaihong/clop
本次更新内容
如果输入错误选项,会推荐正确选项
- 示例代码
package main import ( "fmt" "github.com/guonaihong/clop" ) type T struct { Num int `clop:"--num" usage:"a"` Rate int `clop:"--rate" usage:"b"` } func main() { t := T{} clop.Bind(&t) fmt.Printf("%d:%d\n", clop.GetIndex("a"), clop.GetIndex("b")) fmt.Printf("%v\n", t) }
- 输出
./t --number error: Found argument '--number' which wasn't expected, or isn't valid in this context Did you mean --num? For more information try --help