Files
coder/cli/server_slim.go
Mathias Fredriksson f1f9cb030d refactor(cli): avoid importing coderd in slim server (#9483)
This small change removes 11 MB from the slim binary size.

Ref: #9380
2023-09-01 13:32:21 +00:00

37 lines
863 B
Go

//go:build slim
package cli
import (
"fmt"
"io"
"os"
"github.com/coder/coder/v2/cli/clibase"
"github.com/coder/coder/v2/cli/cliui"
)
func (r *RootCmd) Server(_ func()) *clibase.Cmd {
root := &clibase.Cmd{
Use: "server",
Short: "Start a Coder server",
// We accept RawArgs so all commands and flags are accepted.
RawArgs: true,
Hidden: true,
Handler: func(inv *clibase.Invocation) error {
serverUnsupported(inv.Stderr)
return nil
},
}
return root
}
func serverUnsupported(w io.Writer) {
_, _ = fmt.Fprintf(w, "You are using a 'slim' build of Coder, which does not support the %s subcommand.\n", cliui.DefaultStyles.Code.Render("server"))
_, _ = fmt.Fprintln(w, "")
_, _ = fmt.Fprintln(w, "Please use a build of Coder from GitHub releases:")
_, _ = fmt.Fprintln(w, " https://github.com/coder/coder/releases")
os.Exit(1)
}