You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
boundary/internal/cmd/format.go

35 lines
642 B

package cmd
import (
"os"
"github.com/hashicorp/watchtower/internal/cmd/base"
"github.com/mitchellh/cli"
)
type Formatter interface {
//Output(ui cli.Ui, secret *api.Secret, data interface{}) error
Format(data interface{}) ([]byte, error)
}
var Formatters = map[string]Formatter{
"json": base.JsonFormatter{},
"table": base.TableFormatter{},
"yaml": base.YamlFormatter{},
"yml": base.YamlFormatter{},
}
func Format(ui cli.Ui) string {
switch ui.(type) {
case *WatchtowerUI:
return ui.(*WatchtowerUI).format
}
format := os.Getenv(base.EnvWatchtowerCLIFormat)
if format == "" {
format = "table"
}
return format
}