-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem This Solves
Issue #21 proposes a ? per-line prefix to mark individual shell lines as requiring confirmation. However, there are situations where an operator wants to step through every command in a block interactively — for example, when running an unfamiliar Opsfile for the first time, auditing what a command actually does in a given environment, or exercising extra caution during a sensitive production incident.
A global --confirm / -c flag provides this safety net without requiring every line in the Opsfile to be prefixed with ?.
Proposal
Add a -c / --confirm CLI flag that forces interactive confirmation before executing every shell line, regardless of whether the line carries a ? prefix.
Usage:
ops --confirm prod rollback
ops -c prod restart-pods
Runtime behaviour:
When --confirm is active, ops treats every shell line as if it had a ? prefix:
- Prints the fully resolved command (variables substituted) to stdout
- Prompts:
Execute? [y/N]: yorY→ executes the line normally- Anything else (including empty Enter) → prints
Skipped.and moves to the next line - Execution continues through all remaining lines (each prompted individually)
Interaction with other flags and prefixes:
?-prefixed lines (Issue feat: confirm-before-execute prefix syntax for destructive Opsfile commands #21):--confirmis additive — lines already marked?behave identically; unmarkded lines gain the same behaviour--dry-run: takes precedence — no prompts shown, resolved commands printed with a[confirm]annotation--silent: does not suppress confirmation prompts (same as?prefix behaviour)-(ignore-error prefix) and@(suppress-echo prefix): unaffected by--confirm
Example session:
$ ops --confirm prod deploy
aws s3 sync ./dist s3://my-bucket/
Execute? [y/N]: y
... (aws output) ...
aws cloudfront create-invalidation --distribution-id ABCDEF
Execute? [y/N]:
Skipped.
Acceptance Criteria
Flag parsing:
-
-cand--confirmare accepted as equivalent flags -
--confirmis reflected inOpsFlagsasConfirm bool - Unknown or conflicting flag combinations produce a clear error (none expected, but document interaction with
--dry-run)
Executor:
- When
--confirmis set and stdin is a TTY: every shell line is printed and prompted withExecute? [y/N]:before execution -
yorYexecutes the line; any other input skips it and printsSkipped. - When stdin is not a TTY (piped/scripted):
--confirmis ignored and all lines execute without prompting (non-interactive mode must not hang) -
--dry-runtakes precedence over--confirm: no prompts shown; resolved lines printed with[confirm]annotation - Lines with a
?prefix (Issue feat: confirm-before-execute prefix syntax for destructive Opsfile commands #21) and--confirmactive behave identically to lines without?and--confirmactive — no double-prompting - Exit code behaviour is unchanged: a confirmed line that exits non-zero still stops execution (unless
-prefix is also set)
Tests:
- Flag parser test:
-cand--confirmboth setOpsFlags.Confirm - Executor test:
--confirmprompts for every line;yexecutes, non-yskips - Executor test: non-TTY stdin with
--confirmexecutes all lines without prompting - Executor test:
--dry-run --confirmprints annotation, no prompt - Executor test:
?-prefixed line with--confirmdoes not double-prompt