github.com/jaypipes/ghw@v0.21.1/cmd/ghwc/commands/memory.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  	"github.com/jaypipes/ghw"
    11  	"github.com/pkg/errors"
    12  	"github.com/spf13/cobra"
    13  )
    14  
    15  // memoryCmd represents the install command
    16  var memoryCmd = &cobra.Command{
    17  	Use:   "memory",
    18  	Short: "Show memory information for the host system",
    19  	RunE:  showMemory,
    20  }
    21  
    22  // showMemory show memory information for the host system.
    23  func showMemory(cmd *cobra.Command, args []string) error {
    24  	mem, err := ghw.Memory()
    25  	if err != nil {
    26  		return errors.Wrap(err, "error getting memory info")
    27  	}
    28  
    29  	printInfo(mem)
    30  	return nil
    31  }
    32  
    33  func init() {
    34  	rootCmd.AddCommand(memoryCmd)
    35  }