Skip to content

Commit 5e308df

Browse files
chore: add command for showing colors
1 parent 9dc8e0f commit 5e308df

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

cmd/cliui/main.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/coder/coder/v2/cli/cliui"
1919
"github.com/coder/coder/v2/coderd/database/dbtime"
2020
"github.com/coder/coder/v2/codersdk"
21+
"github.com/coder/pretty"
2122
"github.com/coder/serpent"
2223
)
2324

@@ -37,6 +38,43 @@ func main() {
3738
},
3839
}
3940

41+
root.Children = append(root.Children, &serpent.Command{
42+
Use: "colors",
43+
Handler: func(inv *serpent.Invocation) error {
44+
msg := pretty.Sprint(cliui.DefaultStyles.Code, "This is a code message")
45+
_, _ = fmt.Fprintln(inv.Stdout, msg)
46+
47+
msg = pretty.Sprint(cliui.DefaultStyles.DateTimeStamp, "This is a datetimestamp message")
48+
_, _ = fmt.Fprintln(inv.Stdout, msg)
49+
50+
msg = pretty.Sprint(cliui.DefaultStyles.Error, "This is an error message")
51+
_, _ = fmt.Fprintln(inv.Stdout, msg)
52+
53+
msg = pretty.Sprint(cliui.DefaultStyles.Field, "This is a field message")
54+
_, _ = fmt.Fprintln(inv.Stdout, msg)
55+
56+
msg = pretty.Sprint(cliui.DefaultStyles.Keyword, "This is a keyword message")
57+
_, _ = fmt.Fprintln(inv.Stdout, msg)
58+
59+
msg = pretty.Sprint(cliui.DefaultStyles.Placeholder, "This is a placeholder message")
60+
_, _ = fmt.Fprintln(inv.Stdout, msg)
61+
62+
msg = pretty.Sprint(cliui.DefaultStyles.Prompt, "This is a prompt message")
63+
_, _ = fmt.Fprintln(inv.Stdout, msg)
64+
65+
msg = pretty.Sprint(cliui.DefaultStyles.FocusedPrompt, "This is a focused prompt message")
66+
_, _ = fmt.Fprintln(inv.Stdout, msg)
67+
68+
msg = pretty.Sprint(cliui.DefaultStyles.Fuchsia, "This is a fuchsia prompt message")
69+
_, _ = fmt.Fprintln(inv.Stdout, msg)
70+
71+
msg = pretty.Sprint(cliui.DefaultStyles.Warn, "This is a warning message")
72+
_, _ = fmt.Fprintln(inv.Stdout, msg)
73+
74+
return nil
75+
},
76+
})
77+
4078
root.Children = append(root.Children, &serpent.Command{
4179
Use: "prompt",
4280
Handler: func(inv *serpent.Invocation) error {

0 commit comments

Comments
 (0)