reuse argv and argvlen
use switch to calculate timeout
call is_valid_command in XS