github.com/jaypipes/ghw@v0.21.1/cmd/ghwc/commands/print_util.go (about)

     1  //
     2  // Use and distribution licensed under the Apache license version 2.
     3  //
     4  // See the COPYING file in the root project directory for full text.
     5  //
     6  
     7  package commands
     8  
     9  import "fmt"
    10  
    11  type formattable interface {
    12  	String() string
    13  	JSONString(bool) string
    14  	YAMLString() string
    15  }
    16  
    17  func printInfo(f formattable) {
    18  	switch outputFormat {
    19  	case outputFormatHuman:
    20  		fmt.Printf("%s\n", f)
    21  	case outputFormatJSON:
    22  		fmt.Printf("%s\n", f.JSONString(pretty))
    23  	case outputFormatYAML:
    24  		fmt.Printf("%s", f.YAMLString())
    25  	}
    26  }