mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
chore(cli): replace lipgloss with coder/pretty (#9564)
This change will improve over CLI performance and "snappiness" as well as substantially reduce our test times. Preliminary benchmarks show `coder server --help` times cut from 300ms to 120ms on my dogfood instance. The inefficiency of lipgloss disproportionately impacts our system, as all help text for every command is generated whenever any command is invoked. The `pretty` API could clean up a lot of the code (e.g., by replacing complex string concatenations with Printf), but this commit is too expansive as is so that work will be done in a follow up.
This commit is contained in:
@ -17,6 +17,7 @@ import (
|
||||
"cdr.dev/slog"
|
||||
"github.com/coder/coder/v2/cli/cliui"
|
||||
"github.com/coder/coder/v2/cryptorand"
|
||||
"github.com/coder/pretty"
|
||||
"github.com/coder/wgtunnel/tunnelsdk"
|
||||
)
|
||||
|
||||
@ -114,8 +115,8 @@ func readOrGenerateConfig(customTunnelHost string) (Config, error) {
|
||||
|
||||
if cfg.Version == 0 {
|
||||
_, _ = fmt.Println()
|
||||
_, _ = fmt.Println(cliui.DefaultStyles.Error.Render("You're running a deprecated tunnel version!"))
|
||||
_, _ = fmt.Println(cliui.DefaultStyles.Error.Render("Upgrading you to the new version now. You will need to rebuild running workspaces."))
|
||||
pretty.Printf(cliui.DefaultStyles.Error, "You're running a deprecated tunnel version.\n")
|
||||
pretty.Printf(cliui.DefaultStyles.Error, "Upgrading you to the new version now. You will need to rebuild running workspaces.")
|
||||
_, _ = fmt.Println()
|
||||
|
||||
cfg, err := GenerateConfig(customTunnelHost)
|
||||
@ -172,8 +173,8 @@ func GenerateConfig(customTunnelHost string) (Config, error) {
|
||||
|
||||
spin.Stop()
|
||||
_, _ = fmt.Printf("Using tunnel in %s with latency %s.\n",
|
||||
cliui.DefaultStyles.Keyword.Render(locationName),
|
||||
cliui.DefaultStyles.Code.Render(node.AvgLatency.String()),
|
||||
cliui.Keyword(locationName),
|
||||
cliui.Code(node.AvgLatency.String()),
|
||||
)
|
||||
|
||||
return Config{
|
||||
|
Reference in New Issue
Block a user