Skip to content

Commit

Permalink
Add db import cmd (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: Benji Visser <[email protected]>
  • Loading branch information
noqcks authored Aug 9, 2023
1 parent 737f99d commit ab0a90d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/db_import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"

"github.com/xeol-io/xeol/internal"
"github.com/xeol-io/xeol/xeol/db"
)

var dbImportCmd = &cobra.Command{
Use: "import FILE",
Short: "import an EOL database archive",
Long: fmt.Sprintf("import an EOL database archive from a local FILE.\nDB archives can be obtained from %q.", internal.DBUpdateURL),
Args: cobra.ExactArgs(1),
RunE: runDBImportCmd,
}

func init() {
dbCmd.AddCommand(dbImportCmd)
}

func runDBImportCmd(_ *cobra.Command, args []string) error {
dbCurator, err := db.NewCurator(appConfig.DB.ToCuratorConfig())
if err != nil {
return err
}

if err := dbCurator.ImportFrom(args[0]); err != nil {
return fmt.Errorf("unable to import EOL database: %+v", err)
}

return stderrPrintLnf("EOL database imported")
}

0 comments on commit ab0a90d

Please sign in to comment.