2019-01-08 16:57:24 +08:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
configCmd.AddCommand(configExportCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
var configExportCmd = &cobra.Command{
|
2019-01-09 00:37:02 +08:00
|
|
|
Use: "export <path>",
|
2019-01-09 00:09:25 +08:00
|
|
|
Short: "Export the configuration to a file",
|
2019-01-09 00:37:02 +08:00
|
|
|
Long: `Export the configuration to a file. The path must be for a
|
|
|
|
json or yaml file. This exported configuration can be changed,
|
|
|
|
and imported again with 'config import' command.`,
|
|
|
|
Args: jsonYamlArg,
|
2019-01-08 16:57:24 +08:00
|
|
|
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
|
|
|
|
settings, err := d.store.Settings.Get()
|
|
|
|
checkErr(err)
|
|
|
|
|
2019-01-08 22:07:55 +08:00
|
|
|
server, err := d.store.Settings.GetServer()
|
|
|
|
checkErr(err)
|
|
|
|
|
2019-01-08 16:57:24 +08:00
|
|
|
auther, err := d.store.Auth.Get(settings.AuthMethod)
|
|
|
|
checkErr(err)
|
|
|
|
|
|
|
|
data := &settingsFile{
|
|
|
|
Settings: settings,
|
|
|
|
Auther: auther,
|
2019-01-08 22:07:55 +08:00
|
|
|
Server: server,
|
2019-01-08 16:57:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = marshal(args[0], data)
|
|
|
|
checkErr(err)
|
|
|
|
}, pythonConfig{}),
|
|
|
|
}
|