Skip to content

Commit ed500cc

Browse files
tashianclaude
andcommitted
Propagate --non-interactive flag to environment variable
Add a Before hook that sets STEP_NON_INTERACTIVE=1 when the --non-interactive flag is used, allowing ui.CanPrompt() to detect the flag without needing access to the cli context. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b119584 commit ed500cc

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

internal/cmd/root.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ func newApp(stdout, stderr io.Writer) *cli.App {
148148
EnvVar: "STEP_NON_INTERACTIVE",
149149
})
150150

151+
// Before hook to propagate --non-interactive flag to the environment
152+
// so that ui.CanPrompt() can check it without access to the cli context.
153+
app.Before = func(ctx *cli.Context) error {
154+
if ctx.GlobalBool("non-interactive") {
155+
os.Setenv("STEP_NON_INTERACTIVE", "1")
156+
}
157+
return nil
158+
}
159+
151160
// Action runs on `step` or `step <command>` if the command is not enabled.
152161
app.Action = func(ctx *cli.Context) error {
153162
args := ctx.Args()

0 commit comments

Comments
 (0)