-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Benji Visser <[email protected]>
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |