Consume positional source/target left-to-right across commands#81
Merged
Conversation
sync/replicate/plan, bootstrap, and probe consumed positional args by fixed index (args[0]→source, args[1]→target), so `--source-url URL <target>` left the lone positional in args[0] and the target slot empty — sync/bootstrap/plan errored with "requires source and target"; probe failed silently, dropping the target and probing only the source. Extract the left-to-right consumption that convert-sha256 already did correctly into a shared resolvePositionalEndpoints helper, and route all four commands through it. When a positional is left over after both slots are filled (e.g. a flag-supplied source plus two positionals), reject it rather than silently ignoring one — the fixed-index code dropped a positional here too. Add a table test covering the mixed forms and the over-specified case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: b21841a5f646
pjbgf
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
sync/replicate/plan,bootstrap, andprobeconsumed positional args by fixed index (args[0]→source,args[1]→target):So
--source-url URL <target>left the lone positional inargs[0]and the target slot empty:sync/bootstrap/planerrored with "requires source and target".probefailed silently — the target was dropped and only the source probed.convert-sha256already did the correct left-to-right consumption (resolveConvertSHA256Args); the rule was just never applied to the others.Fix
Extract that left-to-right consumption into a shared
resolvePositionalEndpoints(source, target *string, args []string) errorhelper and route all four commands through it. When a positional is left over after both slots are filled — e.g. a flag-supplied source plus two positionals (sync --source-url X a b) — it returns an error rather than silently ignoring one (the old fixed-index code dropped a positional here too). This complementscobra.MaximumNArgs(2), which only bounds the count.fetchis intentionally left alone — it takes a single source-only positional, has no mixed-form ambiguity, and doesn't fit the two-endpoint helper.Tests
args_test.gocovers both-positional, source-flag+positional-target, target-flag+positional-source, both-flags, source-only, and the two over-specified cases that must now error. ExistingresolveConvertSHA256Argstable test still passes against the shared helper.🤖 Generated with Claude Code
Note
Low Risk
CLI-only argument parsing; behavior change is more correct invocation and stricter rejection of ambiguous extra positionals, with no auth or sync-engine logic touched.
Overview
Fixes mixed flag/positional usage so forms like
--source-url URL <target>correctly fill the target slot instead of treating the lone positional as source and failing (or, for probe, silently dropping the target).Adds shared
resolvePositionalEndpointsinflags.goand wires bootstrap, probe, sync / replicate / plan, and convert-sha256 through it, replacing fixedargs[0]/args[1]indexing. Extra positionals after both endpoints are set now return an explicit error instead of being ignored.args_test.goexercises mixed flag/positional cases and the over-specified error paths.Reviewed by Cursor Bugbot for commit 653abf2. Configure here.