cmd/tailscale/cli: add initial predicate func ActLikeCLI

This commit is contained in:
Brad Fitzpatrick 2020-07-15 18:56:07 -07:00
parent 45578b47f3
commit 44baa3463f
1 changed files with 15 additions and 0 deletions

View File

@ -23,6 +23,21 @@ import (
"tailscale.com/safesocket"
)
// ActLikeCLI reports whether a GUI application should act like the
// CLI based on os.Args, GOOS, the context the process is running in
// (pty, parent PID), etc.
func ActLikeCLI() bool {
if len(os.Args) < 2 {
// TODO: on Windows & Mac, show usage if we're being run with a pty.
return false
}
switch os.Args[1] {
case "up", "status", "netcheck":
return true
}
return false
}
// Run runs the CLI. The args do npot include the binary name.
func Run(args []string) error {
rootfs := flag.NewFlagSet("tailscale", flag.ExitOnError)