v0.0.3版本
#33
可以获取命令行选项优先级别
package main
import (
"fmt"
"github.com/guonaihong/clop"
)
type cat struct {
NumberNonblank bool `clop:"-b;--number-nonblank"
usage:"number nonempty output lines, overrides"`
ShowEnds bool `clop:"-E;--show-ends"
usage:"display $ at end of each line"`
}
func main() {
c := cat{}
clop.Bind(&c)
if clop.GetIndex("number-nonblank") < clop.GetIndex("show-ends") {
fmt.Printf("cat -b -E\n")
} else {
fmt.Printf("cat -E -b \n")
}
}
// cat -be
// 输出 cat -b -E
// cat -Eb
// 输出 cat -E -b