Skip to content

feat: add - prefix to ignore non-zero exit codes in Opsfile commands (Issue #20)#43

Merged
seanseannery merged 3 commits intomainfrom
feat/dash-prefix-silent-failure
Mar 9, 2026
Merged

feat: add - prefix to ignore non-zero exit codes in Opsfile commands (Issue #20)#43
seanseannery merged 3 commits intomainfrom
feat/dash-prefix-silent-failure

Conversation

@seanseannery
Copy link
Owner

Key Changes

  • Add IgnoreError bool field to ResolvedLine in internal/command_resolver.go
  • Replace single @ prefix check in Resolve() with a loop that handles @, -, -@, @- in any order (at most one of each consumed)
  • Add IgnoreError check in internal/executor.go — uses errors.As(err, &exitErr) with *exec.ExitError so only non-zero exit codes are ignored; system-level errors (shell not found, permission denied) still propagate
  • Add redeploy example command to examples/Opsfile demonstrating - and -@ prefixes
  • Add design doc at docs/feat-dash-prefix-silent-failure.md and test plan at docs/testplans/testplan-dash-prefix-silent-failure.md

Why do we need this?

Closes #20. Ops currently stops on the first shell line that returns a non-zero exit code. Some operations (e.g. docker stop, rm -f, killall) may legitimately fail without indicating a real problem. This adds Makefile-style - prefix support so users can mark individual lines as failure-tolerant, allowing execution to continue to the next line.

New modules or other dependencies introduced

None. Uses errors.As from the standard library (already imported).

How was this tested?

  • 20 new unit tests in internal/command_resolver_test.go covering: - stripping, combined -@/@-, -- (double-dash), -@-/@-@ edge cases, dash in middle of line, dash in variable values, multi-line continuation, whitespace after dash
  • 9 new unit tests in internal/executor_test.go covering: ignored exit codes, system errors still propagate (invalid shell test), combined IgnoreError+Silent, all-lines IgnoreError, exit code 127 ignored
  • internal/opsfile_parser_test.go updated for new redeploy example command
  • All existing @ prefix tests (20+) pass with the refactored loop-based prefix stripping
  • make lint and make test pass cleanly

@seanseannery seanseannery merged commit 6facd3c into main Mar 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opsfiles support '-' bash prefix to silence failures and proceed execution on subsequent lines like Makefile syntax

1 participant