cmd/tailscale/cli: omit "file" subcommand if taildrop is omitted from build

Updates #15812
Updates #12614

Change-Id: Ic945b26a127ba15399abdaab8fe43b1cfa64d874
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2025-05-06 21:18:46 -07:00 committed by Brad Fitzpatrick
parent 7cc2837594
commit 48dacf1bf7
2 changed files with 26 additions and 9 deletions

View File

@ -207,6 +207,8 @@ func noDupFlagify(c *ffcli.Command) {
}
}
var fileCmd func() *ffcli.Command
func newRootCmd() *ffcli.Command {
rootfs := newFlagSet("tailscale")
rootfs.Func("socket", "path to tailscaled socket", func(s string) error {
@ -247,7 +249,7 @@ change in the future.
serveCmd(),
versionCmd,
webCmd,
fileCmd,
nilOrCall(fileCmd),
bugReportCmd,
certCmd,
netlockCmd,
@ -286,6 +288,13 @@ func nonNilCmds(cmds ...*ffcli.Command) []*ffcli.Command {
return slicesx.AppendNonzero(cmds[:0], cmds)
}
func nilOrCall(f func() *ffcli.Command) *ffcli.Command {
if f == nil {
return nil
}
return f()
}
func fatalf(format string, a ...any) {
if Fatalf != nil {
Fatalf(format, a...)

View File

@ -1,6 +1,8 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
//go:build !ts_omit_taildrop
package cli
import (
@ -38,14 +40,20 @@ import (
"tailscale.com/version"
)
var fileCmd = &ffcli.Command{
Name: "file",
ShortUsage: "tailscale file <cp|get> ...",
ShortHelp: "Send or receive files",
Subcommands: []*ffcli.Command{
fileCpCmd,
fileGetCmd,
},
func init() {
fileCmd = getFileCmd
}
func getFileCmd() *ffcli.Command {
return &ffcli.Command{
Name: "file",
ShortUsage: "tailscale file <cp|get> ...",
ShortHelp: "Send or receive files",
Subcommands: []*ffcli.Command{
fileCpCmd,
fileGetCmd,
},
}
}
type countingReader struct {