cli/cmd/os_import.go

43 lines
921 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 osImportCmd = &cobra.Command{
Use: "import",
Aliases: []string{"im", "sync", "load"},
Short: "Import configurations from a USB stick",
Long: `
This commands triggers an import action from a connected USB stick with
configuration to load for the Home Assistant Operating System.
`,
Example: `
ha os import
`,
Run: func(cmd *cobra.Command, args []string) {
log.WithField("args", args).Debug("os import")
section := "os"
command := "config/sync"
base := viper.GetString("endpoint")
resp, err := helper.GenericJSONPost(base, section, command, nil)
if err != nil {
fmt.Println(err)
ExitWithError = true
} else {
ExitWithError = !helper.ShowJSONResponse(resp)
}
},
}
func init() {
osCmd.AddCommand(osImportCmd)
}