mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +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:
@ -22,16 +22,26 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &clibase.Cmd{
|
||||
var root *clibase.Cmd
|
||||
root = &clibase.Cmd{
|
||||
Use: "cliui",
|
||||
Short: "Used for visually testing UI components for the CLI.",
|
||||
HelpHandler: func(inv *clibase.Invocation) error {
|
||||
_, _ = fmt.Fprintln(inv.Stdout, "This command is used for visually testing UI components for the CLI.")
|
||||
_, _ = fmt.Fprintln(inv.Stdout, "It is not intended to be used by end users.")
|
||||
_, _ = fmt.Fprintln(inv.Stdout, "Subcommands: ")
|
||||
for _, child := range root.Children {
|
||||
_, _ = fmt.Fprintf(inv.Stdout, "- %s\n", child.Use)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
root.Children = append(root.Children, &clibase.Cmd{
|
||||
Use: "prompt",
|
||||
Handler: func(inv *clibase.Invocation) error {
|
||||
_, err := cliui.Prompt(inv, cliui.PromptOptions{
|
||||
Text: "What is our " + cliui.DefaultStyles.Field.Render("company name") + "?",
|
||||
Text: "What is our " + cliui.Field("company name") + "?",
|
||||
Default: "acme-corp",
|
||||
Validate: func(s string) error {
|
||||
if !strings.EqualFold(s, "coder") {
|
||||
|
Reference in New Issue
Block a user