Assuming you already have triggers on globals and have a way to enable the string comamnds. Here is what I would do in jass once the command is activated.
Code:
function PS2PID takes string s returns integer
if (s=="red") then
return 0
elseif (s=="blue" then
return 1
//continue for all names
endif
return -1
endfunction
function gift_unit takes nothing returns nothing
local string s=StringCase(GetEventPlayerChatString(),false)
local group g=CreateGroup()
local unit u
//check target player
local integer tar=PS2PID(SubString(s,6,StringLength(s)))
//if cannot get target player - exit the function
if (tar==-1) then
return
endif
//go thourhg all the picked units
loop
set u=FirstOfGroup(g)
exitwhen u==null
//check that you are giving your OWN unit
if (GetOwningPlayer(u)==GetTriggerPlayer()) then
call SetUnitOwner(u,Player(tar),true)
endif
endloop
//fix memory leaks
call DestroyGroup(g)
set g=null
set s=""
endfunction
didnt test it tough...