Files
filebrowser/cmd/config_export.go
T

47 lines
944 B
Go
Raw Normal View History

2019-01-08 08:57:24 +00:00
package cmd
import (
"github.com/spf13/cobra"
)
func init() {
configCmd.AddCommand(configExportCmd)
}
var configExportCmd = &cobra.Command{
2019-01-08 16:37:02 +00:00
Use: "export <path>",
2019-01-08 16:09:25 +00:00
Short: "Export the configuration to a file",
2019-01-08 16:37:02 +00: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,
RunE: python(func(_ *cobra.Command, args []string, d *pythonData) error {
2019-01-08 08:57:24 +00:00
settings, err := d.store.Settings.Get()
if err != nil {
return err
}
2019-01-08 08:57:24 +00:00
2019-01-08 14:07:55 +00:00
server, err := d.store.Settings.GetServer()
if err != nil {
return err
}
2019-01-08 14:07:55 +00:00
2019-01-08 08:57:24 +00:00
auther, err := d.store.Auth.Get(settings.AuthMethod)
if err != nil {
return err
}
2019-01-08 08:57:24 +00:00
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)
if err != nil {
return err
}
return nil
2019-01-08 08:57:24 +00:00
}, pythonConfig{}),
}