cmd/tailscale/cli: add initial predicate func ActLikeCLI

pull/569/head
Brad Fitzpatrick 4 years ago
parent 45578b47f3
commit 44baa3463f

@ -23,6 +23,21 @@ import (
"tailscale.com/safesocket" "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. // Run runs the CLI. The args do npot include the binary name.
func Run(args []string) error { func Run(args []string) error {
rootfs := flag.NewFlagSet("tailscale", flag.ExitOnError) rootfs := flag.NewFlagSet("tailscale", flag.ExitOnError)

Loading…
Cancel
Save