func Display()

in pkg/display/display.go [58:88]


func Display(ctx *cli.Context, displayable *d.Displayable) error {
	displayStyle := ctx.String("display")
	if displayStyle == "" {
		commandFullName := ctx.Command.FullName()
		if commandFullName != "" {
			displayStyle = getDisplayStyle(commandFullName)
		} else {
			for _, c := range ctx.Lineage() {
				if s := getDisplayStyle(c.Args().First()); s != "" {
					displayStyle = s
					break
				}
			}
		}
	}
	if displayStyle == "" {
		displayStyle = "json"
	}
	switch strings.ToLower(displayStyle) {
	case JSON:
		return json.Display(displayable)
	case YAML:
		return yaml.Display(displayable)
	case TABLE:
		return table.Display(displayable)
	case GRAPH:
		return graph.Display(ctx, displayable)
	default:
		return fmt.Errorf("unsupported display style: %s", displayStyle)
	}
}