cmd/tailscale/cli: don't ExitOnError on js/wasm

An os.Exit brings down the whole wasm module.

Updates #3157

Change-Id: I3daa97fd854715b901f3dbb04b57d841576b60b1
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-10-27 13:57:05 -07:00
parent b0b0a80318
commit 75de4e9cc2
11 changed files with 20 additions and 12 deletions

View File

@@ -77,6 +77,14 @@ func ActLikeCLI() bool {
return false
}
func newFlagSet(name string) *flag.FlagSet {
onError := flag.ExitOnError
if runtime.GOOS == "js" {
onError = flag.ContinueOnError
}
return flag.NewFlagSet(name, onError)
}
// Run runs the CLI. The args do not include the binary name.
func Run(args []string) error {
if len(args) == 1 && (args[0] == "-V" || args[0] == "--version") {
@@ -90,7 +98,7 @@ func Run(args []string) error {
})
})
rootfs := flag.NewFlagSet("tailscale", flag.ExitOnError)
rootfs := newFlagSet("tailscale")
rootfs.StringVar(&rootArgs.socket, "socket", paths.DefaultTailscaledSocket(), "path to tailscaled's unix socket")
rootCmd := &ffcli.Command{