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 (
target = flag.String("target", "", "specify target (ios, tvos, android, js)")
archNames = flag.String("arch", "", "specify architecture(s) to include")
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)")
appID = flag.String("appid", "org.gioui.app", "app identifier (for -buildmode=exe)")
verbose = flag.Bool("v", false, "verbose output")
target = flag.String("target", "", "specify target (ios, tvos, android, js)")
archNames = flag.String("arch", "", "specify architecture(s) to include")
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)")
appID = flag.String("appid", "org.gioui.app", "app identifier (for -buildmode=exe)")
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 {
@@ -89,7 +90,11 @@ func build(bi *buildInfo) error {
if err != nil {
return err
}
defer os.RemoveAll(tmpDir)
if *keepWorkdir {
fmt.Fprintf(os.Stderr, "WORKDIR=%s\n", tmpDir)
} else {
defer os.RemoveAll(tmpDir)
}
switch *target {
case "js":
return buildJS(bi)
@@ -108,7 +113,7 @@ func errorf(format string, args ...interface{}) {
}
func runCmdRaw(cmd *exec.Cmd) ([]byte, error) {
if *verbose {
if *printCommands {
fmt.Printf("%s\n", strings.Join(cmd.Args, " "))
}
out, err := cmd.Output()