func Validate(opts *ImportOptions) error {
	if opts.Engine == "" {
		return fmt.Errorf("import options is missing the engine")
	}
	if opts.Port == "" {
		return fmt.Errorf("import options is missing the port")
	}
	if opts.Hostname == "" {
		return fmt.Errorf("import options is missing the hostname")
	}
	return nil
}
Validate takes import options and returns an
error if the options are missing details
we need to run the import.
package database
import (
	"fmt"
	"io/ioutil"
	"os/exec"
	"syscall"
	"github.com/craftcms/nitro/pkg/pathexists"
)
var (
	MySQLImportCommand    = "mysql"
	PostgresImportCommand = "psql"
)
type Importer interface {
	Import(opts *ImportOptions, finder func(engine, version string) (string, error)) error
}
type ImportOptions struct {
	Compressed      bool
	CompressionType string
	Engine          string
	Version         string
	Hostname        string
	Port            string
	DatabaseName    string
	File            string
}
type importer struct{}
func NewImporter() *importer {
	return &importer{}
}
func (importer *importer) Import(opts *ImportOptions, find func(engine, version string) (string, error)) error {
	if opts == nil {
		return fmt.Errorf("no options were provider")
	}
	if err := Validate(opts); err != nil {
		return err
	}
	if !pathexists.IsFile(opts.File) {
		return fmt.Errorf("unable to file the file %s", opts.File)
	}
	tool, err := find(opts.Engine, opts.Version)
	if err != nil {
		return err
	}
	var createCommand, importCommand []string
	switch opts.Engine {
	case "postgres":
		createCommand = []string{fmt.Sprintf("--host=%s", opts.Hostname), "--port=" + opts.Port, "--username=nitro", fmt.Sprintf(`-c CREATE DATABASE %s;`, opts.DatabaseName)}
		importCommand = []string{fmt.Sprintf("--host=%s", opts.Hostname), "--port=" + opts.Port, "--username=nitro", opts.DatabaseName, "--file=" + opts.File}
	default:
		createCommand = []string{"--user=nitro", fmt.Sprintf("--host=%s", opts.Hostname), "-pnitro", fmt.Sprintf(`-e CREATE DATABASE IF NOT EXISTS %s;`, opts.DatabaseName)}
		importCommand = []string{"--user=nitro", fmt.Sprintf("--host=%s", opts.Hostname), "-pnitro", opts.DatabaseName, fmt.Sprintf(`-e source %s`, opts.File)}
	}
	if createCommand != nil {
		if err := importer.exec(tool, createCommand); err != nil {
			fmt.Println(err)
		}
	}
	if err := importer.exec(tool, importCommand); err != nil {
		return err
	}
	return nil
}
func (importer *importer) exec(tool string, commands []string) error {
	c := exec.Command(tool, commands...)
	c.Stderr = ioutil.Discard
	c.Stdout = ioutil.Discard
	if err := c.Start(); err != nil {
		return fmt.Errorf("unable to start the command: %w", err)
	}
	if err := c.Wait(); err != nil {
		if exiterr, ok := err.(*exec.ExitError); ok {
			if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
				return fmt.Errorf("Exit Status: %d", status.ExitStatus())
			}
		} else {
			return err
		}
	}
	return nil
}