github.com/liquid-dev/text@v0.3.3-liquid/cmd/gotext/generate.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "github.com/liquid-dev/text/message/pipeline" 9 ) 10 11 func init() { 12 out = cmdGenerate.Flag.String("out", "", "output file to write to") 13 } 14 15 var cmdGenerate = &Command{ 16 Run: runGenerate, 17 UsageLine: "generate <package>", 18 Short: "generates code to insert translated messages", 19 } 20 21 func runGenerate(cmd *Command, config *pipeline.Config, args []string) error { 22 config.Packages = args 23 s, err := pipeline.Extract(config) 24 if err != nil { 25 return wrap(err, "extraction failed") 26 } 27 if err := s.Import(); err != nil { 28 return wrap(err, "import failed") 29 } 30 return wrap(s.Generate(), "generation failed") 31 }