Skip to content

feat: add --dry-run flag to toggle-on, toggle-off, and archive commands#677

Merged
nieblara merged 13 commits intomainfrom
feat/dry-run-flag
Apr 14, 2026
Merged

feat: add --dry-run flag to toggle-on, toggle-off, and archive commands#677
nieblara merged 13 commits intomainfrom
feat/dry-run-flag

Conversation

@nieblara
Copy link
Copy Markdown
Contributor

@nieblara nieblara commented Apr 14, 2026

Adds --dry-run to the three hand-rolled flag commands (toggle-on, toggle-off, archive). When set, the API validates the patch without persisting it and returns a preview of the flag after the change would be applied.

The LaunchDarkly API already supports dryRun=true as a query parameter on PATCH /api/v2/flags/{projectKey}/{featureFlagKey}. The auto-generated ldcli flags update --dry-run true already works, but the hand-rolled commands passed nil for query params and had no way to send it.

Changes

  • cmd/cliflags/flags.go — add DryRunFlag constant and description
  • cmd/flags/toggle.go — register --dry-run boolean flag, build url.Values{"dryRun": ["true"]} when set, pass to MakeRequest
  • cmd/flags/archive.go — same pattern
  • internal/resources/mock_client.go — add Query url.Values field so tests can verify query params are passed
  • cmd/flags/toggle_test.go — two new tests: --dry-run passes dryRun=true, omitting it passes nothing
  • cmd/flags/archive_test.go — same two tests

Not in scope

  • Segments — no hand-rolled segment commands; ldcli segments update already exposes --dry-run via codegen
  • Workflows — in maintenance mode / planned for deprecation
  • Output formatting — API returns the same flag preview shape for dry-run, so existing rendering works as-is

Made with Cursor


Note

Low Risk
Low risk: small, opt-in CLI flag that only changes request query parameters when explicitly set, plus test/mocking updates.

Overview
Adds a new --dry-run CLI flag for flags archive, flags toggle-on, and flags toggle-off that, when set, sends dryRun=true as a query parameter on the underlying PATCH /api/v2/flags/... request.

Updates the resources MockClient to record request query params and adds coverage to ensure dryRun is passed only when --dry-run is provided.

Reviewed by Cursor Bugbot for commit 5eb2a6f. Bugbot is set up for automated code reviews on this repo. Configure here.

nieblara added 11 commits March 17, 2026 20:02
* [feat] Agent friendly error handling

* feat(REL-12755): adding --fields flag (#662)

* [feat] adding --fields flag

* feat(REL-15756): updating agent friendly and improved rich text output (#663)

feat(REL-15756) updating agent friendly and improved rich text output
Three tests in root_test.go still asserted the old `name (key)` bullet
format, but the toggle-on command now passes ResourceName: "flags" which
triggers key-value output. Update to match the actual output shape.

Made-with: Cursor
Remove the standalone `fields []string` positional parameter from
CmdOutput and pass fields exclusively through CmdOutputOpts.Fields.
This eliminates the dual-path API and simplifies every call site.

Also emit a stderr warning when --fields is used with plaintext output,
since the flag is silently ignored in that mode.

Made-with: Cursor
…ELOG

Add entries for the error JSON shape change (new statusCode/suggestion
fields, message casing) and the plaintext table format change. Both are
breaking changes that should be called out for v3.0.

Made-with: Cursor
The API already supports dryRun as a query parameter on PATCH
/api/v2/flags. The auto-generated `flags update` command exposes it,
but the hand-rolled toggle and archive commands passed nil for query
params. This wires --dry-run through to MakeRequest on all three.

Also adds a Query field to MockClient so tests can verify query params.

Made-with: Cursor
Comment thread cmd/flags/toggle_test.go Outdated
Copy-paste error had both dry-run subtests invoking toggle-on instead
of toggle-off, so toggle-off's --dry-run path was never exercised.

Made-with: Cursor
Base automatically changed from REL-12752-tty-1 to main April 14, 2026 17:00
@nieblara nieblara requested a review from a team April 14, 2026 17:18
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5eb2a6f. Configure here.

Comment thread cmd/flags/toggle.go
path,
"application/json",
nil,
query,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dry-run plaintext output misleadingly says "Successfully updated"

Medium Severity

When --dry-run is set and plaintext output is used, CmdOutput is called with the hardcoded action "update", which produces the prefix "Successfully updated". Nothing was actually persisted — the API only validated and returned a preview. A user seeing "Successfully updated" after explicitly requesting --dry-run may believe the mutation was applied, undermining the purpose of the flag.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5eb2a6f. Configure here.

@nieblara nieblara merged commit ad4ab2d into main Apr 14, 2026
15 checks passed
@nieblara nieblara deleted the feat/dry-run-flag branch April 14, 2026 20:01
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.

3 participants