cmd/gio: rename -v to -x and add -work

The verbose flag only triggered printing of commands, which is
traditionally named -x by other Go tools.

The -work flag will print and preserve the temporary directory.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-11 11:11:06 +02:00
parent 896f5a77dd
commit 828a695086
+13 -8
View File
@@ -14,12 +14,13 @@ import (
) )
var ( var (
target = flag.String("target", "", "specify target (ios, tvos, android, js)") target = flag.String("target", "", "specify target (ios, tvos, android, js)")
archNames = flag.String("arch", "", "specify architecture(s) to include") archNames = flag.String("arch", "", "specify architecture(s) to include")
buildMode = flag.String("buildmode", "exe", "specify buildmode: archive or exe") buildMode = flag.String("buildmode", "exe", "specify buildmode: archive or exe")
destPath = flag.String("o", "", "output file (Android .aar or .apk file) or directory (iOS/tvOS .framework or webassembly files)") destPath = flag.String("o", "", "output file (Android .aar or .apk file) or directory (iOS/tvOS .framework or webassembly files)")
appID = flag.String("appid", "org.gioui.app", "app identifier (for -buildmode=exe)") appID = flag.String("appid", "org.gioui.app", "app identifier (for -buildmode=exe)")
verbose = flag.Bool("v", false, "verbose output") printCommands = flag.Bool("x", false, "print the commands")
keepWorkdir = flag.Bool("work", false, "print the name of the temporary work directory and do not delete it when exiting.")
) )
type buildInfo struct { type buildInfo struct {
@@ -89,7 +90,11 @@ func build(bi *buildInfo) error {
if err != nil { if err != nil {
return err return err
} }
defer os.RemoveAll(tmpDir) if *keepWorkdir {
fmt.Fprintf(os.Stderr, "WORKDIR=%s\n", tmpDir)
} else {
defer os.RemoveAll(tmpDir)
}
switch *target { switch *target {
case "js": case "js":
return buildJS(bi) return buildJS(bi)
@@ -108,7 +113,7 @@ func errorf(format string, args ...interface{}) {
} }
func runCmdRaw(cmd *exec.Cmd) ([]byte, error) { func runCmdRaw(cmd *exec.Cmd) ([]byte, error) {
if *verbose { if *printCommands {
fmt.Printf("%s\n", strings.Join(cmd.Args, " ")) fmt.Printf("%s\n", strings.Join(cmd.Args, " "))
} }
out, err := cmd.Output() out, err := cmd.Output()