...
1
2
3
4
5 package main
6
7 import (
8 "golang.org/x/text/message/pipeline"
9 )
10
11 var cmdGenerate = &Command{
12 Init: initGenerate,
13 Run: runGenerate,
14 UsageLine: "generate <package> [-out <gofile>]",
15 Short: "generates code to insert translated messages",
16 }
17
18 func initGenerate(cmd *Command) {
19 out = cmd.Flag.String("out", "", "output file to write to")
20 }
21
22 func runGenerate(cmd *Command, config *pipeline.Config, args []string) error {
23 config.Packages = args
24 s, err := pipeline.Extract(config)
25 if err != nil {
26 return wrap(err, "extraction failed")
27 }
28 if err := s.Import(); err != nil {
29 return wrap(err, "import failed")
30 }
31 if err := s.Merge(); err != nil {
32 return wrap(err, "merge failed")
33 }
34 return wrap(s.Generate(), "generation failed")
35 }
36
View as plain text