#!/usr/bin/env bash

cat <<EOF >mise.toml
redactions = ["SECRET"]
[env]
SECRET = "my_secret"

[tasks.a]
run = 'echo secret: \$SECRET'
EOF

assert "mise run a" "secret: [redacted]"

cat <<EOF >mise.toml
redactions = ["secret"]
[tasks.a]
run = 'echo secret: {{ vars.secret }}'

[vars]
secret = "my_secret"
EOF
assert "mise run a" "secret: [redacted]"

cat <<EOF >mise.toml
redactions = ["SECRET*"]
[env]
SECRET_FOO = "my_secret_wild"

[tasks.a]
run = 'echo secret: \$SECRET_FOO'
EOF
assert "mise run a" "secret: [redacted]"

cat <<EOF >mise.toml
[env]
SECRET= {value = "my_secret", redact = true}

[tasks.a]
run = 'echo secret: \$SECRET'
EOF
assert "mise run a" "secret: [redacted]"

echo '{ "SECRET": "my_secret" }' >.env.json
cat <<EOF >mise.toml
[env]
_.file = {path = ".env.json", redact = true}

[tasks.a]
run = 'echo secret: \$SECRET'
EOF
assert "mise run a" "secret: [redacted]"
