Add new "webbrowser" and "colorable" feature tags so that the github.com/toqueteos/webbrowser and mattn/go-colorable packages can be excluded from minbox builds. Updates #12614 Change-Id: Iabd38b242f5a56aa10ef2050113785283f4e1fe8 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>main
parent
5eaaf9786b
commit
a3215f1f9d
@ -0,0 +1,28 @@ |
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_colorable
|
||||
|
||||
package cli |
||||
|
||||
import ( |
||||
"io" |
||||
"os" |
||||
|
||||
"github.com/mattn/go-colorable" |
||||
"github.com/mattn/go-isatty" |
||||
) |
||||
|
||||
// colorableOutput returns a colorable writer if stdout is a terminal (not, say,
|
||||
// redirected to a file or pipe), the Stdout writer is os.Stdout (we're not
|
||||
// embedding the CLI in wasm or a mobile app), and NO_COLOR is not set (see
|
||||
// https://no-color.org/). If any of those is not the case, ok is false
|
||||
// and w is Stdout.
|
||||
func colorableOutput() (w io.Writer, ok bool) { |
||||
if Stdout != os.Stdout || |
||||
os.Getenv("NO_COLOR") != "" || |
||||
!isatty.IsTerminal(os.Stdout.Fd()) { |
||||
return Stdout, false |
||||
} |
||||
return colorable.NewColorableStdout(), true |
||||
} |
||||
@ -0,0 +1,12 @@ |
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build ts_omit_colorable
|
||||
|
||||
package cli |
||||
|
||||
import "io" |
||||
|
||||
func colorableOutput() (w io.Writer, ok bool) { |
||||
return Stdout, false |
||||
} |
||||
@ -0,0 +1,12 @@ |
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_webbrowser
|
||||
|
||||
package cli |
||||
|
||||
import "github.com/toqueteos/webbrowser" |
||||
|
||||
func init() { |
||||
hookOpenURL.Set(webbrowser.Open) |
||||
} |
||||
@ -0,0 +1,13 @@ |
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build ts_omit_colorable
|
||||
|
||||
package buildfeatures |
||||
|
||||
// HasColorable is whether the binary was built with support for modular feature "Colorized terminal output".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_colorable" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasColorable = false |
||||
@ -0,0 +1,13 @@ |
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build !ts_omit_colorable
|
||||
|
||||
package buildfeatures |
||||
|
||||
// HasColorable is whether the binary was built with support for modular feature "Colorized terminal output".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_colorable" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasColorable = true |
||||
@ -0,0 +1,13 @@ |
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build ts_omit_webbrowser
|
||||
|
||||
package buildfeatures |
||||
|
||||
// HasWebBrowser is whether the binary was built with support for modular feature "Open URLs in the user's web browser".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_webbrowser" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasWebBrowser = false |
||||
@ -0,0 +1,13 @@ |
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build !ts_omit_webbrowser
|
||||
|
||||
package buildfeatures |
||||
|
||||
// HasWebBrowser is whether the binary was built with support for modular feature "Open URLs in the user's web browser".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_webbrowser" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasWebBrowser = true |
||||
Loading…
Reference in new issue