github.com/gsquire/gb@v0.4.4-0.20161112235727-3982dc872064/cmd/gb/plugin.go (about) 1 package main 2 3 import ( 4 "os/exec" 5 6 "github.com/constabulary/gb/cmd" 7 "github.com/pkg/errors" 8 ) 9 10 func init() { 11 registerCommand(PluginCmd) 12 } 13 14 var PluginCmd = &cmd.Command{ 15 Name: "plugin", 16 Short: "plugin information", 17 Long: `gb supports git style plugins. 18 19 A gb plugin is anything in the $PATH with the prefix gb-. In other words 20 gb-something, becomes gb something. 21 22 gb plugins are executed from the parent gb process with the environment 23 variable, GB_PROJECT_DIR set to the root of the current project. 24 25 gb plugins can be executed directly but this is rarely useful, so authors 26 should attempt to diagnose this by looking for the presence of the 27 GB_PROJECT_DIR environment key. 28 `, 29 } 30 31 func lookupPlugin(arg string) (string, error) { 32 plugin := "gb-" + arg 33 path, err := exec.LookPath(plugin) 34 return path, errors.Wrapf(err, "plugin: unable to locate %q", plugin) 35 }