Introduce -pkg parameter to define package name for UI code.

master
Icedream 2016-05-13 02:59:18 +02:00
parent bb2f57592b
commit 6f3bcb07a2
1 changed files with 7 additions and 6 deletions

View File

@ -22,6 +22,7 @@ import (
var forceUpdate *bool = flag.Bool("force", false, "forces code generation for up-to-date files") var forceUpdate *bool = flag.Bool("force", false, "forces code generation for up-to-date files")
var translatable *bool = flag.Bool("tr", false, "adds calls to a user provided 'func tr(source string, context ...string) string' that returns a translation of the source argument, using provided context args for disambiguation") var translatable *bool = flag.Bool("tr", false, "adds calls to a user provided 'func tr(source string, context ...string) string' that returns a translation of the source argument, using provided context args for disambiguation")
var packageName *string = flag.String("pkg", "main", "defines the package name for which to generate the code")
type String struct { type String struct {
Text string `xml:"string"` Text string `xml:"string"`
@ -891,19 +892,19 @@ func writeActionInitializations(buf *bytes.Buffer, actions []*Action) error {
func generateUICode(buf *bytes.Buffer, ui *UI) error { func generateUICode(buf *bytes.Buffer, ui *UI) error {
// Comment, package decl, imports // Comment, package decl, imports
buf.WriteString( buf.WriteString(fmt.Sprintf(
`// This file was created by ui2walk and may be regenerated. `// This file was created by ui2walk and may be regenerated.
// DO NOT EDIT OR YOUR MODIFICATIONS WILL BE LOST! // DO NOT EDIT OR YOUR MODIFICATIONS WILL BE LOST!
//+build windows //+build windows
package main package %s
import ( import (
"github.com/lxn/walk" "github.com/lxn/walk"
) )
`) `, *packageName))
// Embed the corresponding Walk type. // Embed the corresponding Walk type.
var embeddedType string var embeddedType string