github.com/pluralsh/plural-cli@v0.9.5/cmd/plural/pr.go (about) 1 package plural 2 3 import ( 4 "github.com/pluralsh/plural-cli/pkg/pr" 5 "github.com/urfave/cli" 6 ) 7 8 func prCommands() []cli.Command { 9 return []cli.Command{ 10 { 11 Name: "template", 12 Usage: "applies a pr template resource in the local source tree", 13 Action: handlePrTemplate, 14 Flags: []cli.Flag{ 15 cli.StringFlag{ 16 Name: "file", 17 Usage: "the file the template was placed in", 18 Required: true, 19 }, 20 cli.StringFlag{ 21 Name: "templates", 22 Usage: "a directory of external templates to use for creating new files", 23 Required: false, 24 }, 25 }, 26 }, 27 } 28 } 29 30 func handlePrTemplate(c *cli.Context) error { 31 template, err := pr.Build(c.String("file")) 32 if err != nil { 33 return err 34 } 35 36 if template.Spec.Creates != nil { 37 template.Spec.Creates.ExternalDir = c.String("templates") 38 } 39 40 return pr.Apply(template) 41 }