MCPcopy Index your code
hub / github.com/coder/coder / main

Function main

cmd/cliui/main.go:25–397  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23)
24
25func main() {
26 var root *serpent.Command
27 root = &serpent.Command{
28 Use: "cliui",
29 Short: "Used for visually testing UI components for the CLI.",
30 HelpHandler: func(inv *serpent.Invocation) error {
31 _, _ = fmt.Fprintln(inv.Stdout, "This command is used for visually testing UI components for the CLI.")
32 _, _ = fmt.Fprintln(inv.Stdout, "It is not intended to be used by end users.")
33 _, _ = fmt.Fprintln(inv.Stdout, "Subcommands: ")
34 for _, child := range root.Children {
35 _, _ = fmt.Fprintf(inv.Stdout, "- %s\n", child.Use)
36 }
37 return nil
38 },
39 }
40
41 root.Children = append(root.Children, &serpent.Command{
42 Use: "colors",
43 Hidden: true,
44 Handler: func(inv *serpent.Invocation) error {
45 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.Code, "This is a code message")
46 _, _ = fmt.Fprintln(inv.Stdout)
47
48 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.DateTimeStamp, "This is a datetimestamp message")
49 _, _ = fmt.Fprintln(inv.Stdout)
50
51 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.Error, "This is an error message")
52 _, _ = fmt.Fprintln(inv.Stdout)
53
54 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.Field, "This is a field message")
55 _, _ = fmt.Fprintln(inv.Stdout)
56
57 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.Keyword, "This is a keyword message")
58 _, _ = fmt.Fprintln(inv.Stdout)
59
60 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.Placeholder, "This is a placeholder message")
61 _, _ = fmt.Fprintln(inv.Stdout)
62
63 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.Prompt, "This is a prompt message")
64 _, _ = fmt.Fprintln(inv.Stdout)
65
66 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.FocusedPrompt, "This is a focused prompt message")
67 _, _ = fmt.Fprintln(inv.Stdout)
68
69 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.Fuchsia, "This is a fuchsia message")
70 _, _ = fmt.Fprintln(inv.Stdout)
71
72 pretty.Fprintf(inv.Stdout, cliui.DefaultStyles.Warn, "This is a warning message")
73 _, _ = fmt.Fprintln(inv.Stdout)
74
75 return nil
76 },
77 })
78
79 root.Children = append(root.Children, &serpent.Command{
80 Use: "prompt",
81 Handler: func(inv *serpent.Invocation) error {
82 _, err := cliui.Prompt(inv, cliui.PromptOptions{

Callers

nothing calls this directly

Calls 15

PromptFunction · 0.92
FieldFunction · 0.92
SelectFunction · 0.92
NowFunction · 0.92
ProvisionerJobFunction · 0.92
AgentFunction · 0.92
WorkspaceResourcesFunction · 0.92
ExternalAuthFunction · 0.92
DurationMethod · 0.80
ExitMethod · 0.80
closeFuncFuncType · 0.70
NewMethod · 0.65

Tested by

no test coverage detected