github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/backend/local/cli.go (about)

     1  package local
     2  
     3  import (
     4  	"log"
     5  
     6  	"github.com/hashicorp/terraform/backend"
     7  )
     8  
     9  // backend.CLI impl.
    10  func (b *Local) CLIInit(opts *backend.CLIOpts) error {
    11  	b.CLI = opts.CLI
    12  	b.CLIColor = opts.CLIColor
    13  	b.ShowDiagnostics = opts.ShowDiagnostics
    14  	b.ContextOpts = opts.ContextOpts
    15  	b.OpInput = opts.Input
    16  	b.OpValidation = opts.Validation
    17  	b.RunningInAutomation = opts.RunningInAutomation
    18  
    19  	// configure any new cli options
    20  	if opts.StatePath != "" {
    21  		log.Printf("[TRACE] backend/local: CLI option -state is overriding state path to %s", opts.StatePath)
    22  		b.OverrideStatePath = opts.StatePath
    23  	}
    24  
    25  	if opts.StateOutPath != "" {
    26  		log.Printf("[TRACE] backend/local: CLI option -state-out is overriding state output path to %s", opts.StateOutPath)
    27  		b.OverrideStateOutPath = opts.StateOutPath
    28  	}
    29  
    30  	if opts.StateBackupPath != "" {
    31  		log.Printf("[TRACE] backend/local: CLI option -backup is overriding state backup path to %s", opts.StateBackupPath)
    32  		b.OverrideStateBackupPath = opts.StateBackupPath
    33  	}
    34  
    35  	return nil
    36  }