refine getOpts
add warning and error handler