本文整理汇总了Golang中github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander.Command类的典型用法代码示例。如果您正苦于以下问题:Golang Command类的具体用法?Golang Command怎么用?Golang Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Command类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: commandsCmd
func commandsCmd(c *commander.Command, args []string) error {
var listCmds func(c *commander.Command)
listCmds = func(c *commander.Command) {
u.POut("%s\n", c.FullSpacedName())
for _, sc := range c.Subcommands {
listCmds(sc)
}
}
listCmds(c.Parent)
return nil
}
示例2: commandsHelpCmd
func commandsHelpCmd(c *commander.Command, args []string) error {
u.POut(referenceHeaderMsg)
u.POut("Generated on %s.\n\n", time.Now().UTC().Format("2006-01-02"))
var printCmds func(*commander.Command, int)
printCmds = func(c *commander.Command, level int) {
u.POut("%s ", strings.Repeat("#", level))
u.POut("%s\n\n", c.FullSpacedName())
u.POut("```\n")
u.POut("%s\n", c.Long)
u.POut("```\n\n")
for _, sc := range c.Subcommands {
printCmds(sc, level+1)
}
}
printCmds(c.Parent.Parent, 1)
return nil
}
示例3: ex_run_cmd_cmd1
func ex_run_cmd_cmd1(cmd *commander.Command, args []string) error {
name := "my-cmd-" + cmd.Name()
quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
fmt.Printf("%s: hello from cmd1 (quiet=%v)\n", name, quiet)
return nil
}