aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/script-utils/logfmt/formatflags.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/go/script-utils/logfmt/formatflags.go')
-rw-r--r--client/go/script-utils/logfmt/formatflags.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/client/go/script-utils/logfmt/formatflags.go b/client/go/script-utils/logfmt/formatflags.go
new file mode 100644
index 00000000000..097746d696f
--- /dev/null
+++ b/client/go/script-utils/logfmt/formatflags.go
@@ -0,0 +1,41 @@
+package logfmt
+
+import (
+ "fmt"
+ "strings"
+)
+
+type OutputFormat int
+
+const (
+ FormatVespa OutputFormat = iota //default is vespa
+ FormatRaw
+ FormatJSON
+)
+
+func (v *OutputFormat) Type() string {
+ return "output format"
+}
+
+func (v *OutputFormat) String() string {
+ flagNames := []string{
+ "vespa",
+ "raw",
+ "json",
+ }
+ return flagNames[*v]
+}
+
+func (v *OutputFormat) Set(val string) error {
+ switch strings.ToLower(val) {
+ case "vespa":
+ *v = FormatVespa
+ case "raw":
+ *v = FormatRaw
+ case "json":
+ *v = FormatJSON
+ default:
+ return fmt.Errorf("'%s' is not a valid format argument", val)
+ }
+ return nil
+}