common-cli: arguments parsing improvement

Please add more comment to describe what's the logic is. The code in this method is not obvious what it is doing.