...

Source file src/golang.org/x/text/cmd/gotext/generate.go

Documentation: golang.org/x/text/cmd/gotext

     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  	"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