flag plus 让flag单个标记支持多个参数
https://code.csdn.net/leezjl/flagp/tree/master
- 添加 flagp.StringSlice(name string, value []string, usage string)
- 添加 flagp.StringSliceVar(p *[]string, name string, value []string, usage string)
Example
b := flagp.Bool("b", false, "bool")
dirs := flagp.StringSlice("d", []string{}, "需要操作的文件/目录, tab切起来")
n := flagp.Int("n", 0, "number")
xFiles := flagp.StringSlice("x", []string{}, "需要忽略的文件/目录, tab切起来")
flagp.Parse()
flagp.Usage()
fmt.Println("dirs = ", *dirs, "xFiles = ", *xFiles, "n = ", *n, "b = ", *b)
$ go run upfl.go -b -d hehe/ xx/ -n 123 -x xx/ dd/
Usage of upfl:
-b bool
-d []string
需要操作的文件/目录, tab切起来
-n int
number
-x []string
需要忽略的文件/目录, tab切起来
dirs = [hehe/ xx/] , xFiles = [xx/ dd/] , n = 123 , b = true
来源:CSDN
作者:唐小宗
链接:https://blog.csdn.net/leezjl/article/details/71169913