cli/cmd/host_info.go

41 lines
847 B
Go

package cmd
import (
"fmt"
helper "github.com/home-assistant/cli/client"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var hostInfoCmd = &cobra.Command{
Use: "info",
Aliases: []string{"in", "inf"},
Short: "Provides information on the host system",
Long: `
This command provides information on the host system Home Assistant is
running on`,
Example: `
ha host info`,
Run: func(cmd *cobra.Command, args []string) {
log.WithField("args", args).Debug("host info")
section := "host"
command := "info"
base := viper.GetString("endpoint")
resp, err := helper.GenericJSONGet(base, section, command)
if err != nil {
fmt.Println(err)
ExitWithError = true
} else {
ExitWithError = !helper.ShowJSONResponse(resp)
}
},
}
func init() {
hostCmd.AddCommand(hostInfoCmd)
}