Move getopts out of extra

Should help towards finishing #8784.