github.com/jaypipes/ghw@v0.21.1/cmd/ghwc/commands/bios.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 ( 10 "fmt" 11 12 "github.com/jaypipes/ghw" 13 "github.com/pkg/errors" 14 "github.com/spf13/cobra" 15 ) 16 17 // biosCmd represents the install command 18 var biosCmd = &cobra.Command{ 19 Use: "bios", 20 Short: "Show BIOS information for the host system", 21 RunE: showBIOS, 22 } 23 24 // showBIOS shows BIOS host system. 25 func showBIOS(cmd *cobra.Command, args []string) error { 26 bios, err := ghw.BIOS() 27 if err != nil { 28 return errors.Wrap(err, "error getting BIOS info") 29 } 30 31 switch outputFormat { 32 case outputFormatHuman: 33 fmt.Printf("%v\n", bios) 34 case outputFormatJSON: 35 fmt.Printf("%s\n", bios.JSONString(pretty)) 36 case outputFormatYAML: 37 fmt.Printf("%s", bios.YAMLString()) 38 } 39 return nil 40 } 41 42 func init() { 43 rootCmd.AddCommand(biosCmd) 44 }