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

Function NewOutputFormatter

cli/cliui/output.go:29–49  ·  view source on GitHub ↗

NewOutputFormatter creates a new OutputFormatter with the given formats. The first format is the default format. At least two formats must be provided.

(formats ...OutputFormat)

Source from the content-addressed store, hash-verified

27// NewOutputFormatter creates a new OutputFormatter with the given formats. The
28// first format is the default format. At least two formats must be provided.
29func NewOutputFormatter(formats ...OutputFormat) *OutputFormatter {
30 if len(formats) < 2 {
31 panic("at least two output formats must be provided")
32 }
33
34 formatIDs := make(map[string]struct{}, len(formats))
35 for _, format := range formats {
36 if format.ID() == "" {
37 panic("output format ID must not be empty")
38 }
39 if _, ok := formatIDs[format.ID()]; ok {
40 panic("duplicate format ID: " + format.ID())
41 }
42 formatIDs[format.ID()] = struct{}{}
43 }
44
45 return &OutputFormatter{
46 formats: formats,
47 formatID: formats[0].ID(),
48 }
49}
50
51// AttachOptions attaches the --output flag to the given command, and any
52// additional flags required by the output formatters.

Callers 15

templatePresetsListMethod · 0.92
showOrganizationRolesMethod · 0.92
templateListMethod · 0.92
whoamiMethod · 0.92
workspaceACLToTableFunction · 0.92
scheduleShowMethod · 0.92
taskStatusMethod · 0.92
provisionerJobsListMethod · 0.92
taskLogsMethod · 0.92

Calls 1

IDMethod · 0.65

Tested by 1

Test_OutputFormatterFunction · 0.74