github.com/orteth01/up@v0.2.0/internal/cli/run/run.go (about) 1 package run 2 3 import ( 4 "github.com/apex/up/internal/cli/root" 5 "github.com/apex/up/internal/stats" 6 "github.com/apex/up/internal/util" 7 "github.com/pkg/errors" 8 "github.com/tj/kingpin" 9 ) 10 11 func init() { 12 cmd := root.Command("run", "Run a hook.") 13 cmd.Example(`up run build`, "Run build hook.") 14 cmd.Example(`up run clean`, "Run clean hook.") 15 16 hook := cmd.Arg("hook", "Name of the hook to run.").Required().String() 17 18 cmd.Action(func(_ *kingpin.ParseContext) error { 19 _, p, err := root.Init() 20 if err != nil { 21 return errors.Wrap(err, "initializing") 22 } 23 24 defer util.Pad()() 25 26 stats.Track("Hook", map[string]interface{}{ 27 "name": *hook, 28 }) 29 30 return p.RunHook(*hook) 31 }) 32 }