示例#1
0
文件: main.go 项目: bryanwb/kh
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
0
文件: main.go 项目: jamesbjackson/kh
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
0
文件: main.go 项目: bryanwb/kh
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
0
文件: main.go 项目: bryanwb/kh
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
0
文件: main.go 项目: bryanwb/kh
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
0
文件: main.go 项目: bryanwb/kh
func fingerInvoked(h *kh.Hand, arg string) bool {
	return kh.Contains(h.FingerNames(), arg)
}
示例#7
0
文件: main.go 项目: jamesbjackson/kh
func fingerInvoked(h *kh.Hand, args []string) bool {
	if len(args) < 2 {
		return false
	}
	return kh.Contains(h.FingerNames(), args[1])
}