feat: add --dry-run flag to toggle-on, toggle-off, and archive commands#677
feat: add --dry-run flag to toggle-on, toggle-off, and archive commands#677
Conversation
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
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
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
| path, | ||
| "application/json", | ||
| nil, | ||
| query, |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 5eb2a6f. Configure here.


Adds
--dry-runto 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=trueas a query parameter onPATCH /api/v2/flags/{projectKey}/{featureFlagKey}. The auto-generatedldcli flags update --dry-run truealready works, but the hand-rolled commands passednilfor query params and had no way to send it.Changes
cmd/cliflags/flags.go— addDryRunFlagconstant and descriptioncmd/flags/toggle.go— register--dry-runboolean flag, buildurl.Values{"dryRun": ["true"]}when set, pass toMakeRequestcmd/flags/archive.go— same patterninternal/resources/mock_client.go— addQuery url.Valuesfield so tests can verify query params are passedcmd/flags/toggle_test.go— two new tests:--dry-runpassesdryRun=true, omitting it passes nothingcmd/flags/archive_test.go— same two testsNot in scope
ldcli segments updatealready exposes--dry-runvia codegenMade 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-runCLI flag forflags archive,flags toggle-on, andflags toggle-offthat, when set, sendsdryRun=trueas a query parameter on the underlyingPATCH /api/v2/flags/...request.Updates the resources
MockClientto record request query params and adds coverage to ensuredryRunis passed only when--dry-runis provided.Reviewed by Cursor Bugbot for commit 5eb2a6f. Bugbot is set up for automated code reviews on this repo. Configure here.