Add command line options support, check return codes