Tidied up command-line option parsing in preparation for allowing the query string to be specified as a command-line option.