func (terragruntOptions *TerragruntOptions) AppendTerraformCliArgs(argsToAppend ...string) {
	terragruntOptions.TerraformCliArgs = append(terragruntOptions.TerraformCliArgs, argsToAppend...)
}
Appends the given argsToAppend after the current TerraformCliArgs
package options
import (
	"fmt"
	"io"
	"log"
	"os"
	"path/filepath"
	"time"
	"github.com/gruntwork-io/terragrunt/errors"
	"github.com/gruntwork-io/terragrunt/util"
	"github.com/hashicorp/go-version"
)
var TERRAFORM_COMMANDS_WITH_SUBCOMMAND = []string{
	"debug",
	"force-unlock",
	"state",
}
const DEFAULT_MAX_FOLDERS_TO_CHECK = 100
const TERRAFORM_DEFAULT_PATH = "terraform"
const TerragruntCacheDir = ".terragrunt-cache"
type TerragruntOptions struct {
	TerragruntConfigPath string
	TerraformPath string
	TerraformCommand string
	TerraformVersion *version.Version
	NonInteractive bool
	AutoInit bool
	TerraformCliArgs []string
	WorkingDir string
	Logger *log.Logger
	Env map[string]string
	Source string
	SourceUpdate bool
	DownloadDir string
	IamRole string
	IgnoreDependencyErrors bool
	IgnoreDependencyOrder bool
	IgnoreExternalDependencies bool
	IncludeExternalDependencies bool
	Writer io.Writer
	ErrWriter io.Writer
	MaxFoldersToCheck int
	AutoRetry bool
	MaxRetryAttempts int
	Sleep time.Duration
	RetryableErrors []string
	ExcludeDirs []string
	IncludeDirs []string
	Check bool
	RunTerragrunt func(*TerragruntOptions) error
}
func NewTerragruntOptions(terragruntConfigPath string) (*TerragruntOptions, error) {
	logger := util.CreateLogger("")
	workingDir, downloadDir, err := DefaultWorkingAndDownloadDirs(terragruntConfigPath)
	if err != nil {
		return nil, errors.WithStackTrace(err)
	}
	return &TerragruntOptions{
		TerragruntConfigPath:        terragruntConfigPath,
		TerraformPath:               TERRAFORM_DEFAULT_PATH,
		TerraformCommand:            "",
		AutoInit:                    true,
		NonInteractive:              false,
		TerraformCliArgs:            []string{},
		WorkingDir:                  workingDir,
		Logger:                      logger,
		Env:                         map[string]string{},
		Source:                      "",
		SourceUpdate:                false,
		DownloadDir:                 downloadDir,
		IgnoreDependencyErrors:      false,
		IgnoreDependencyOrder:       false,
		IgnoreExternalDependencies:  false,
		IncludeExternalDependencies: false,
		Writer:                      os.Stdout,
		ErrWriter:                   os.Stderr,
		MaxFoldersToCheck:           DEFAULT_MAX_FOLDERS_TO_CHECK,
		AutoRetry:                   true,
		MaxRetryAttempts:            DEFAULT_MAX_RETRY_ATTEMPTS,
		Sleep:                       DEFAULT_SLEEP,
		RetryableErrors:             util.CloneStringList(RETRYABLE_ERRORS),
		ExcludeDirs:                 []string{},
		IncludeDirs:                 []string{},
		Check:                       false,
		RunTerragrunt: func(terragruntOptions *TerragruntOptions) error {
			return errors.WithStackTrace(RunTerragruntCommandNotSet)
		},
	}, nil
}
func DefaultWorkingAndDownloadDirs(terragruntConfigPath string) (string, string, error) {
	workingDir := filepath.Dir(terragruntConfigPath)
	downloadDir, err := filepath.Abs(filepath.Join(workingDir, TerragruntCacheDir))
	if err != nil {
		return "", "", errors.WithStackTrace(err)
	}
	return workingDir, downloadDir, nil
}
func NewTerragruntOptionsForTest(terragruntConfigPath string) (*TerragruntOptions, error) {
	opts, err := NewTerragruntOptions(terragruntConfigPath)
	if err != nil {
		logger := util.CreateLogger("")
		logger.Printf("error: %v\n", errors.WithStackTrace(err))
		return nil, err
	}
	opts.NonInteractive = true
	return opts, nil
}
func (terragruntOptions *TerragruntOptions) Clone(terragruntConfigPath string) *TerragruntOptions {
	workingDir := filepath.Dir(terragruntConfigPath)
	return &TerragruntOptions{
		TerragruntConfigPath:        terragruntConfigPath,
		TerraformPath:               terragruntOptions.TerraformPath,
		TerraformCommand:            terragruntOptions.TerraformCommand,
		TerraformVersion:            terragruntOptions.TerraformVersion,
		AutoInit:                    terragruntOptions.AutoInit,
		NonInteractive:              terragruntOptions.NonInteractive,
		TerraformCliArgs:            util.CloneStringList(terragruntOptions.TerraformCliArgs),
		WorkingDir:                  workingDir,
		Logger:                      util.CreateLoggerWithWriter(terragruntOptions.ErrWriter, workingDir),
		Env:                         util.CloneStringMap(terragruntOptions.Env),
		Source:                      terragruntOptions.Source,
		SourceUpdate:                terragruntOptions.SourceUpdate,
		DownloadDir:                 terragruntOptions.DownloadDir,
		IamRole:                     terragruntOptions.IamRole,
		IgnoreDependencyErrors:      terragruntOptions.IgnoreDependencyErrors,
		IgnoreDependencyOrder:       terragruntOptions.IgnoreDependencyOrder,
		IgnoreExternalDependencies:  terragruntOptions.IgnoreExternalDependencies,
		IncludeExternalDependencies: terragruntOptions.IncludeExternalDependencies,
		Writer:                      terragruntOptions.Writer,
		ErrWriter:                   terragruntOptions.ErrWriter,
		MaxFoldersToCheck:           terragruntOptions.MaxFoldersToCheck,
		AutoRetry:                   terragruntOptions.AutoRetry,
		MaxRetryAttempts:            terragruntOptions.MaxRetryAttempts,
		Sleep:                       terragruntOptions.Sleep,
		RetryableErrors:             util.CloneStringList(terragruntOptions.RetryableErrors),
		ExcludeDirs:                 terragruntOptions.ExcludeDirs,
		IncludeDirs:                 terragruntOptions.IncludeDirs,
		RunTerragrunt:               terragruntOptions.RunTerragrunt,
	}
}
func (terragruntOptions *TerragruntOptions) InsertTerraformCliArgs(argsToInsert ...string) {
	commandLength := 1
	if util.ListContainsElement(TERRAFORM_COMMANDS_WITH_SUBCOMMAND, terragruntOptions.TerraformCliArgs[0]) {
		commandLength = util.Min(2, len(terragruntOptions.TerraformCliArgs))
	}
	var args []string
	args = append(args, terragruntOptions.TerraformCliArgs[:commandLength]...)
	args = append(args, argsToInsert...)
	args = append(args, terragruntOptions.TerraformCliArgs[commandLength:]...)
	terragruntOptions.TerraformCliArgs = args
}