cli: register event handler first, then do lookup