Factor out common code
Allow either "--" or "-" prefix for options