Skip to content

Commit a02bebd

Browse files
committed
refactor(cli): remove scaletest from slim binary
This change removes 3 MB when combined with #9483. Ref: #9380, #9483
1 parent f1f9cb0 commit a02bebd

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

cli/exp_scaletest.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !slim
2+
13
package cli
24

35
import (

cli/exp_scaletest_slim.go

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//go:build slim
2+
3+
package cli
4+
5+
import "github.com/coder/coder/v2/cli/clibase"
6+
7+
func (r *RootCmd) scaletestCmd() *clibase.Cmd {
8+
cmd := &clibase.Cmd{
9+
Use: "scaletest",
10+
Short: "Run a scale test against the Coder API",
11+
RawArgs: true, // We accept RawArgs so all commands and flags are accepted.
12+
Hidden: true,
13+
Handler: func(inv *clibase.Invocation) error {
14+
slimUnsupported(inv.Stderr, "exp scaletest")
15+
return nil
16+
},
17+
}
18+
19+
return cmd
20+
}

cli/root.go

+10
Original file line numberDiff line numberDiff line change
@@ -1019,3 +1019,13 @@ func (p *prettyErrorFormatter) printf(style lipgloss.Style, format string, a ...
10191019
),
10201020
)
10211021
}
1022+
1023+
func slimUnsupported(w io.Writer, cmd string) {
1024+
_, _ = fmt.Fprintf(w, "You are using a 'slim' build of Coder, which does not support the %s subcommand.\n", cliui.DefaultStyles.Code.Render(cmd))
1025+
_, _ = fmt.Fprintln(w, "")
1026+
_, _ = fmt.Fprintln(w, "Please use a build of Coder from GitHub releases:")
1027+
_, _ = fmt.Fprintln(w, " https://github.com/coder/coder/releases")
1028+
1029+
//nolint:revive
1030+
os.Exit(1)
1031+
}

cli/server_slim.go

+1-14
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
package cli
44

55
import (
6-
"fmt"
7-
"io"
8-
"os"
9-
106
"github.com/coder/coder/v2/cli/clibase"
11-
"github.com/coder/coder/v2/cli/cliui"
127
)
138

149
func (r *RootCmd) Server(_ func()) *clibase.Cmd {
@@ -19,18 +14,10 @@ func (r *RootCmd) Server(_ func()) *clibase.Cmd {
1914
RawArgs: true,
2015
Hidden: true,
2116
Handler: func(inv *clibase.Invocation) error {
22-
serverUnsupported(inv.Stderr)
17+
slimUnsupported(inv.Stderr, "server")
2318
return nil
2419
},
2520
}
2621

2722
return root
2823
}
29-
30-
func serverUnsupported(w io.Writer) {
31-
_, _ = fmt.Fprintf(w, "You are using a 'slim' build of Coder, which does not support the %s subcommand.\n", cliui.DefaultStyles.Code.Render("server"))
32-
_, _ = fmt.Fprintln(w, "")
33-
_, _ = fmt.Fprintln(w, "Please use a build of Coder from GitHub releases:")
34-
_, _ = fmt.Fprintln(w, " https://github.com/coder/coder/releases")
35-
os.Exit(1)
36-
}

0 commit comments

Comments
 (0)