v0.2.6版本
详情可看 #93
对子命令的用法进行优化. @Greyh4t
package main
import (
"fmt"
"github.com/guonaihong/clop"
)
type add struct {
All bool `clop:"-A; --all" usage:"add changes from all tracked and untracked files"`
Force bool `clop:"-f; --force" usage:"allow adding otherwise ignored files"`
Pathspec []string `clop:"args=pathspec"`
}
func (a *add) SubMain() {
// 当add子命令被设置时
// clop会自动调用这个函数
}
type mv struct {
Force bool `clop:"-f; --force" usage:"allow adding otherwise ignored files"`
}
func (m *mv) SubMain() {
// 当mv 子命令被设置时
// clop会自动调用这个函数
}
type git struct {
Add add `clop:"subcommand" usage:"Add file contents to the index"`
Mv mv `clop:"subcommand" usage:"Move or rename a file, a directory, or a symlink"`
}
func main() {
g := git{}
clop.Bind(&g)
}