本文整理汇总了Golang中github.com/bryanwb/kh.Hand类的典型用法代码示例。如果您正苦于以下问题:Golang Hand类的具体用法?Golang Hand怎么用?Golang Hand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hand类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: executeUpdate
func executeUpdate(h *kh.Hand, args []string) {
if err := h.Update(args); err != nil {
log.Errorf("Encountered error updating fingers")
log.Errorf("Error message: %v", err)
os.Exit(1)
}
}
示例2: showHelp
func showHelp(h *kh.Hand) {
helpText := `The King's Hand (kh) is a tool for organizing and executing shellish scripts.
It does your dirty work, so keep it clean.
kh exposes plugins, known as fingers, as subcommands.
Usage:
kh [flags]
kh [finger] [arguments to a finger]
Available Meta-Commands:
version Print the version number of King's Hand
help C'mon, do I have to explain this one?
update [finger] Builds one or more fingers
By default, updates all
Flags:
-H, --hand-home="/Users/hitman/.kh": Home directory for kh
-v, --verbose[=false]: verbose output
Use "kh [finger] --help" for more information about a finger.
`
fmt.Printf(helpText)
if len(h.Fingers) > 0 {
fmt.Printf("Available fingers are:\n%s\n",
strings.Join(h.FingerNames(), "\n"))
} else {
fmt.Printf("Currently no fingers available\n")
}
}
示例3: showList
func showList(h *kh.Hand) {
if len(h.Fingers) > 0 {
fmt.Printf("Available fingers are:\n%s\n",
strings.Join(h.FingerDescriptions(), "\n"))
} else {
fmt.Printf("Currently no fingers available\n")
}
}
示例4: executeFinger
func executeFinger(h *kh.Hand, fingerName string) {
remainingArgs := findFingerArgs(os.Args)
flags := map[string]bool{"help": helpFlag, "verbose": verboseFlag}
if err := h.ExecuteFinger(fingerName, flags, kh.StripFlags(remainingArgs)); err != nil {
log.Errorf("Encountered error executing finger %s", fingerName)
log.Errorf("Error message: %v", err)
os.Exit(1)
}
}
示例5: doInstall
func doInstall(h *kh.Hand, args []string) {
args = kh.StripFlags(args)
if kh.EmptyArgs(args) {
log.Error("You must specify one or more fingers to install")
os.Exit(1)
}
if err := h.InstallFingers(args); err != nil {
log.Error(err.Error())
os.Exit(1)
}
}
示例6: fingerInvoked
func fingerInvoked(h *kh.Hand, arg string) bool {
return kh.Contains(h.FingerNames(), arg)
}
示例7: fingerInvoked
func fingerInvoked(h *kh.Hand, args []string) bool {
if len(args) < 2 {
return false
}
return kh.Contains(h.FingerNames(), args[1])
}