func run()

in cmd/tfimport/main.go [67:100]


func run() error {
	flag.Parse()

	if *showVersion {
		cmd.ShowVersion()
		return nil
	}

	if *inputDir == "" {
		return fmt.Errorf("--input_dir must be set and not be empty")
	}
	// Determine the runners to use.
	var rn runner.Runner = &runner.Default{}
	var importRn runner.Runner = &runner.Default{}
	if *dryRun {
		importRn = &runner.Dry{}
		log.Printf("Dry run mode, logging commands but not executing any imports.")
	} else if *verbose {
		// Use the Multi runner to print temporary output in case the terraform import command freezes.
		rn = &runner.Multi{}
		importRn = &runner.Multi{}
	}

	args := &tfimport.RunArgs{
		InputDir:              *inputDir,
		TerraformPath:         *terraformPath,
		DryRun:                *dryRun,
		Interactive:           *interactive,
		SpecificResourceTypes: resourcesFlag,
		Verbose:               *verbose,
	}

	return tfimport.Run(rn, importRn, args)
}