-
Notifications
You must be signed in to change notification settings - Fork 53
/
output.go
40 lines (34 loc) · 963 Bytes
/
output.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package format
import (
"strings"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
)
type OutputFormat string
const (
// OutputFormat values
Table OutputFormat = "table"
Json OutputFormat = "json"
SimpleJson OutputFormat = "simple-json"
Sarif OutputFormat = "sarif"
)
var OutputFormats = []string{string(Table), string(Json), string(SimpleJson), string(Sarif)}
func GetOutputFormat(formatFlagVal string) (format OutputFormat, err error) {
// Default print format is table.
format = Table
if formatFlagVal != "" {
switch strings.ToLower(formatFlagVal) {
case string(Table):
format = Table
case string(Json):
format = Json
case string(SimpleJson):
format = SimpleJson
case string(Sarif):
format = Sarif
default:
err = errorutils.CheckErrorf("only the following output formats are supported: " + coreutils.ListToText(OutputFormats))
}
}
return
}