Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: tools/proto-gae/proto_gae.go

Issue 1718123003: Add header text to proto-gae tool (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/proto-gae/proto_gae.go
diff --git a/tools/proto-gae/proto_gae.go b/tools/proto-gae/proto_gae.go
index 6db06781b3e1ee3ee3bfcb39f3e37d7f40051e2d..7ec4e5a989da7d647ea66269bdac47588dd1f306 100644
--- a/tools/proto-gae/proto_gae.go
+++ b/tools/proto-gae/proto_gae.go
@@ -24,6 +24,7 @@ type app struct {
packageName string
typeNames stringsetflag.Flag
outFile string
+ header string
}
const help = `Usage of %s:
@@ -40,6 +41,11 @@ methods for the named types.
Options:
`
+const copyright = `// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+`
+
func (a *app) parseArgs(fs *flag.FlagSet, args []string) error {
fs.SetOutput(a.out)
fs.Usage = func() {
@@ -51,6 +57,8 @@ func (a *app) parseArgs(fs *flag.FlagSet, args []string) error {
"A generated proto.Message type to generate stubs for (required, repeatable)")
fs.StringVar(&a.outFile, "out", "proto_gae.gen.go",
"The name of the output file")
+ fs.StringVar(&a.header, "header", copyright, "Header text to put at the top of "+
+ "the generated file. Defaults to the Chromium Authors copyright.")
if err := fs.Parse(args[1:]); err != nil {
return err
@@ -74,7 +82,8 @@ func (a *app) parseArgs(fs *flag.FlagSet, args []string) error {
}
var tmpl = template.Must(
- template.New("main").Parse(`// AUTOGENERATED: Do not edit
+ template.New("main").Parse(`{{if index . "header"}}{{index . "header"}}
+{{end}}// AUTOGENERATED: Do not edit
package {{index . "package"}}
@@ -115,6 +124,7 @@ func (a *app) writeTo(w io.Writer) error {
return tmpl.Execute(w, map[string]interface{}{
"package": a.packageName,
"types": typeNames,
+ "header": a.header,
})
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698