filebrowser/cmd/import.go
1138-4EB 90b7f4aaf6 [WIP] add viper to manage envvars and cfg files
Former-commit-id: 99d241dc790629791b67b7b2ce20a10341a1c1e7 [formerly 08e8410bffdb50134a2d6ccbe853b25d4c4d3fc6] [formerly f32b18d9acb42ee1988c49b7980a16a606cee142 [formerly 1080bfde68]]
Former-commit-id: 318c4f159697e896bcf824e274907c5c03046bf0 [formerly 82533ae817673dfab8d56533f15a9931c0c74c1e]
Former-commit-id: ece42aa8e8c7480a5a21614b6ca397b71a01e1fa
2019-01-06 06:11:15 +01:00

32 lines
803 B
Go

package cmd
import (
"github.com/filebrowser/filebrowser/v2/storage/bolt/importer"
"github.com/spf13/cobra"
v "github.com/spf13/viper"
)
func init() {
rootCmd.AddCommand(importCmd)
importCmd.Flags().String("old.database", "", "")
importCmd.Flags().String("old.config", "", "")
importCmd.MarkFlagRequired("old.database")
}
var importCmd = &cobra.Command{
Use: "import",
Short: "Imports an old configuration",
Long: `Imports an old configuration. This command DOES NOT
import share links because they are incompatible with
this version.`,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
oldDB := mustGetString(cmd, "old.database")
oldConf := mustGetString(cmd, "old.config")
err := importer.Import(oldDB, oldConf, v.GetString("database"))
checkErr(err)
},
}