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) } }
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") } }
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") } }
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) } }
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) } }
func fingerInvoked(h *kh.Hand, arg string) bool { return kh.Contains(h.FingerNames(), arg) }
func fingerInvoked(h *kh.Hand, args []string) bool { if len(args) < 2 { return false } return kh.Contains(h.FingerNames(), args[1]) }