update tofu console docs for non-interactive use-case (#2369)

Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Oleksandr Levchenkov <ollevche@gmail.com>
Co-authored-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
This commit is contained in:
Oleksandr Levchenkov 2025-01-14 19:03:30 +02:00 committed by GitHub
parent 174f1d5784
commit d7af2c4d39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,6 +9,11 @@ description: >-
The `tofu console` command provides an interactive console for
evaluating [expressions](../../language/expressions/index.mdx).
:::warning
The `tofu console` command is not designed for use in scripts. You can use it, but
you may find that some functions don't work as intended.
:::
## Usage
Usage: `tofu console [options]`
@ -54,23 +59,6 @@ There are several other ways to set values for input variables in the root
module, aside from the `-var` and `-var-file` options. Refer to
[Assigning Values to Root Module Variables](../../language/values/variables.mdx#assigning-values-to-root-module-variables) for more information.
## Scripting
The `tofu console` command can be used in non-interactive scripts
by piping newline-separated commands to it. Only the output from the
final command is printed unless an error occurs earlier.
For example:
```shell
$ echo 'split(",", "foo,bar,baz")' | tofu console
tolist([
"foo",
"bar",
"baz",
])
```
## Remote State
If [remote state](../../language/state/remote.mdx) is used by the current backend,