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

Method Format

cli/cliui/output.go:76–84  ·  view source on GitHub ↗

Format formats the given data using the format specified by the --output flag. If the flag is not set, the default format is used.

(ctx context.Context, data any)

Source from the content-addressed store, hash-verified

74// Format formats the given data using the format specified by the --output
75// flag. If the flag is not set, the default format is used.
76func (f *OutputFormatter) Format(ctx context.Context, data any) (string, error) {
77 for _, format := range f.formats {
78 if format.ID() == f.formatID {
79 return format.Format(ctx, data)
80 }
81 }
82
83 return "", xerrors.Errorf("unknown output format %q", f.formatID)
84}
85
86// FormatID will return the ID of the format selected by `--output`.
87// If no flag is present, it returns the 'default' formatter.

Callers 15

templatePresetsListMethod · 0.95
showOrganizationRolesMethod · 0.95
templateListMethod · 0.95
whoamiMethod · 0.95
workspaceACLToTableFunction · 0.95
taskLogsMethod · 0.95
userListMethod · 0.95
userSingleMethod · 0.95
userOIDCClaimsMethod · 0.95

Calls 3

IDMethod · 0.65
FormatMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

Test_OutputFormatterFunction · 0.76