MCPcopy Create free account
hub / github.com/Facets-cloud/flow / ParseFormat

Function ParseFormat

internal/listfmt/listfmt.go:63–73  ·  view source on GitHub ↗

ParseFormat converts a user-supplied string into a Format. Empty string and "table" both yield FormatTable; "json" and "tsv" are the other accepted values. Comparison is case-insensitive and ignores surrounding whitespace.

(s string)

Source from the content-addressed store, hash-verified

61// "table" both yield FormatTable; "json" and "tsv" are the other accepted
62// values. Comparison is case-insensitive and ignores surrounding whitespace.
63func ParseFormat(s string) (Format, error) {
64 switch strings.ToLower(strings.TrimSpace(s)) {
65 case "", "table":
66 return FormatTable, nil
67 case "json":
68 return FormatJSON, nil
69 case "tsv":
70 return FormatTSV, nil
71 }
72 return 0, fmt.Errorf("invalid format %q (want table|json|tsv)", s)
73}
74
75// ANSI color codes used by the color-aware renderers below.
76const (

Callers 6

listTagsCmdFunction · 0.92
listTasksCmdFunction · 0.92
listProjectsCmdFunction · 0.92
listPlaybooksCmdFunction · 0.92
listRunsCmdFunction · 0.92
TestParseFormatFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseFormatFunction · 0.68