2019-01-08 08:57:24 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
configCmd.AddCommand(configExportCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
var configExportCmd = &cobra.Command{
|
|
|
|
Use: "export <filename>",
|
2019-01-08 16:09:25 +00:00
|
|
|
Short: "Export the configuration to a file",
|
|
|
|
Long: "Export the configuration to a file.",
|
2019-01-08 08:57:24 +00:00
|
|
|
Args: jsonYamlArg,
|
|
|
|
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
|
|
|
|
settings, err := d.store.Settings.Get()
|
|
|
|
checkErr(err)
|
|
|
|
|
2019-01-08 14:07:55 +00:00
|
|
|
server, err := d.store.Settings.GetServer()
|
|
|
|
checkErr(err)
|
|
|
|
|
2019-01-08 08:57:24 +00:00
|
|
|
auther, err := d.store.Auth.Get(settings.AuthMethod)
|
|
|
|
checkErr(err)
|
|
|
|
|
|
|
|
data := &settingsFile{
|
|
|
|
Settings: settings,
|
|
|
|
Auther: auther,
|
2019-01-08 14:07:55 +00:00
|
|
|
Server: server,
|
2019-01-08 08:57:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = marshal(args[0], data)
|
|
|
|
checkErr(err)
|
|
|
|
}, pythonConfig{}),
|
|
|
|
}
|