mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
f085af4ba6
This now uses the HCL2 parser and evaluator APIs and evaluates in terms of a new-style *lang.Scope, rather than the old terraform.Interpolator type that is no longer functional. The Context.Eval method used here behaves differently than the Context.Interpolater method used previously: it performs a graph walk to populate transient values such as input variables, local values, and output values, and produces its scope in terms of the result of that graph walk. Because of this, it is a lot more robust than the prior method when asked to resolve references other than those that are persisted in the state.
61 lines
1.0 KiB
Go
61 lines
1.0 KiB
Go
// +build !solaris
|
|
|
|
// The readline library we use doesn't currently support solaris so
|
|
// we just build tag it off.
|
|
|
|
package command
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/hashicorp/terraform/helper/wrappedreadline"
|
|
"github.com/hashicorp/terraform/repl"
|
|
|
|
"github.com/chzyer/readline"
|
|
"github.com/mitchellh/cli"
|
|
)
|
|
|
|
func (c *ConsoleCommand) modeInteractive(session *repl.Session, ui cli.Ui) int {
|
|
// Configure input
|
|
l, err := readline.NewEx(wrappedreadline.Override(&readline.Config{
|
|
Prompt: "> ",
|
|
InterruptPrompt: "^C",
|
|
EOFPrompt: "exit",
|
|
HistorySearchFold: true,
|
|
}))
|
|
if err != nil {
|
|
c.Ui.Error(fmt.Sprintf(
|
|
"Error initializing console: %s",
|
|
err))
|
|
return 1
|
|
}
|
|
defer l.Close()
|
|
|
|
for {
|
|
// Read a line
|
|
line, err := l.Readline()
|
|
if err == readline.ErrInterrupt {
|
|
if len(line) == 0 {
|
|
break
|
|
} else {
|
|
continue
|
|
}
|
|
} else if err == io.EOF {
|
|
break
|
|
}
|
|
|
|
out, exit, diags := session.Handle(line)
|
|
if diags.HasErrors() {
|
|
c.showDiagnostics(diags)
|
|
}
|
|
if exit {
|
|
break
|
|
}
|
|
|
|
ui.Output(out)
|
|
}
|
|
|
|
return 0
|
|
}
|