@@ -332,11 +332,27 @@ async function searchAction(
332332 // ─── Team-prefix grouping ─────────────────────────────────────────────────
333333 const pickTeams : Record < string , string > = { } ;
334334 if ( ! opts . groupByTeamPrefix && opts . pickTeam && opts . pickTeam . length > 0 ) {
335- process . stderr . write (
336- pc . yellow (
337- "warning: --pick-team has no effect without --group-by-team-prefix; picks are being ignored.\n" ,
338- ) ,
339- ) ;
335+ // Emit per-assignment warnings (same validation as when grouping is enabled) — see issue #121.
336+ for ( const assignment of opts . pickTeam ) {
337+ const eqIndex = assignment . indexOf ( "=" ) ;
338+ if ( eqIndex === - 1 ) {
339+ process . stderr . write (
340+ `warning: --pick-team "${ assignment } " is missing the = separator; skipping\n` ,
341+ ) ;
342+ continue ;
343+ }
344+ const combined = assignment . slice ( 0 , eqIndex ) . trim ( ) ;
345+ const chosen = assignment . slice ( eqIndex + 1 ) . trim ( ) ;
346+ if ( ! combined || ! chosen ) {
347+ process . stderr . write (
348+ `warning: --pick-team "${ assignment } " must have non-empty combined and chosen labels; skipping\n` ,
349+ ) ;
350+ continue ;
351+ }
352+ process . stderr . write (
353+ `warning: --pick-team: no section found with label "${ combined } "\n (no combined sections remain)\n` ,
354+ ) ;
355+ }
340356 }
341357 if ( opts . groupByTeamPrefix ) {
342358 const prefixes = opts . groupByTeamPrefix
@@ -368,6 +384,18 @@ async function searchAction(
368384 ) ;
369385 continue ;
370386 }
387+ // Validate that chosen is one of the teams in the combined label — see issue #121.
388+ const combinedCandidates = combined
389+ . split ( " + " )
390+ . map ( ( part ) => part . trim ( ) )
391+ . filter ( ( part ) => part . length > 0 ) ;
392+ if ( combinedCandidates . length > 1 && ! combinedCandidates . includes ( chosen ) ) {
393+ process . stderr . write (
394+ `warning: --pick-team "${ assignment } " has chosen label "${ chosen } " which is not one of the teams in ` +
395+ `"${ combined } ". Allowed choices: ${ combinedCandidates . map ( ( c ) => `"${ c } "` ) . join ( ", " ) } ; skipping\n` ,
396+ ) ;
397+ continue ;
398+ }
371399 const updated = applyTeamPick ( sections , combined , chosen ) ;
372400 if ( updated === sections ) {
373401 // applyTeamPick returns the same reference when the combined label is not found.
0 commit comments