Fix misleading prompt when pcurl add --name X hits a host already covered by another profile#1
Open
kroexov wants to merge 1 commit into
Open
Conversation
Before, `pcurl add --name X <curl>` for a host already covered by a
differently-named profile prompted "Profile \"X\" already exists.
Update?" — but X did not exist. The misleading message came from
collapsing two cases in `confirmExisting`:
1. A profile named X already exists.
2. No profile named X, but another profile already covers the host.
Case 2 still proceeds to create a new profile under X (resulting in
two profiles for the same host), which is intentional and useful for
multi-account setups — only the prompt was wrong.
Split the logic so each case has its own prompt:
* Name collision → existing `ConfirmUpdate` (default Yes), updates X.
* Host conflict → new `ConfirmHostConflict` (default No), creates X
as a separate profile and leaves the original untouched.
Adds `TestAdd_HostConflict_Confirm` / `TestAdd_HostConflict_Decline`.
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.
context: i do not have this profile, i wrote it to set alternative token with different name to same origin

Summary
pcurl add --name X <curl>for a host already covered by a differently-named profile shows:…even when
Xdoes not exist. The confusing message comes fromconfirmExistingcollapsing two distinct cases:Xalready exists.X, but another profile (sayY) already lists this host inMatchHosts.In case 2 the code already creates a new profile
Xindependent ofY(useful for multi-account setups on the same host) — only the prompt was wrong.Changes
internal/pcurl/add.go— splitconfirmExistingso each case has its own prompt.internal/pcurl/prompt.go— addConfirmHostConflict(newName, existingName, host)(huh + text fallback, default No since this creates a duplicate-host profile).internal/pcurl/add_test.go—TestAdd_HostConflict_Confirm/TestAdd_HostConflict_Decline.Name-collision flow (
ConfirmUpdate) is unchanged.Test plan
go test ./internal/pcurl/— all green, including the new testspcurl add --name newname curl <url-of-existing-host>shows the new wording and respects Yes/Nopcurl add --name existing curl <existing-url>still shows the original "already exists. Update?" prompt