Skip to content

v0.2.7版本

Compare
Choose a tag to compare
@guonaihong guonaihong released this 17 Jul 07:47
· 6 commits to master since this release
3d9cd3d

支持设置回调函数, 让clop支持任意类型的数据绑定。

type TestCallback struct {
	Size int `clop:"short;long;callback=ParseSize" usage:"parse size"`
	Max  int `clop:"short;long"`
}

func (t *TestCallback) ParseSize(val string) {
	// 做些解析工作
	// t.Size = 解析之后的值
}

func main() {
 	t := TestCallback{}
	err := clop.Bind(&t)

	fmt.Printf("%#v, %s\n", t, err)
}