Better error messages for command line flags with missing arguments

Partially addresses #9075.