{"record":{"id":"960076e9094d856a","repo":"wpscanteam/wpscan","slug":"one-of-the-following-options-is-required-opt-to","errorCode":null,"errorMessage":"One of the following options is required: #{opt.to_long}, --#{opt.required_unless.join(', --').tr('_', '-')}","messagePattern":"One of the following options is required: #(.+?), --#(.+?)","errorType":"exception","errorClass":"OptParseValidator::NoRequiredOption","httpStatus":null,"severity":"error","filePath":"lib/opt_parse_validator.rb","lineNumber":155,"sourceCode":"          raise e.is_a?(Error) ? e.class : Error, \"#{opt.to_long} #{e}\"\n        end\n      end\n    end\n\n    # Ensure that all required options are supplied\n    # Should be overriden to modify the behavior\n    #\n    # @return [ Void ]\n    def post_processing\n      @opts.each do |opt|\n        raise NoRequiredOption, \"The option #{opt.to_long} is required\" if opt.required? && !@results.key?(opt.to_sym)\n\n        next if opt.required_unless.empty? || @results.key?(opt.to_sym)\n\n        fail_msg = 'One of the following options is required: ' \\\n                   \"#{opt.to_long}, --#{opt.required_unless.join(', --').tr('_', '-')}\"\n\n        raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|\n          @results.key?(sym)\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":137,"sourceCodeEnd":162,"githubUrl":"https://github.com/wpscanteam/wpscan/blob/62c9cef471de90095f6b42245a11d0f8172d19c9/lib/opt_parse_validator.rb#L137-L162","documentation":"Same post_processing pass (lib/opt_parse_validator.rb:155), but for options declared with required_unless: the option itself OR at least one of the listed alternative options must appear in @results, otherwise NoRequiredOption is raised with a message enumerating all acceptable alternatives. In WPScan this is the classic --url constraint: --url is required unless a non-scan action such as --update or --version is given, so a bare 'wpscan' invocation produces exactly this error listing --url plus the alternatives.","triggerScenarios":"Running wpscan with neither --url nor any of the alternative options (--update, --version, help flags); passing the alternative with a typo so its symbol never lands in @results; config file supplying url: but with a wrong key type (e.g. nested under another key) so required_unless.any? { |sym| @results.key?(sym) } stays false.","commonSituations":"New users running plain 'wpscan' expecting a menu; cron/CI jobs meant to run 'wpscan --update' that lost their flags in shell quoting; YAML indentation errors in scan.yml; wrapper scripts that conditionally build the command line and drop both branches.","solutions":["Add --url <target> to the command (most common fix), e.g. wpscan --url https://example.com","Or use one of the alternatives listed in the message verbatim, e.g. wpscan --update or wpscan --version","Or set url: in ~/.config/wpscan/scan.yml / scan.json so @results always contains it","Inspect the message: every acceptable option is listed after the option name; pick one and pass it"],"exampleFix":"# before\n$ wpscan\n# => One of the following options is required: --url, --update, --version ...\n\n# after\n$ wpscan --url https://example.com\n# or\n$ wpscan --update","handlingStrategy":"try-catch","validationCode":"# Ensure the option or one of its required_unless alternatives is supplied\nneeded = %i[url]\nalternatives = %i[update version]\nok = (needed + alternatives).any? { |sym| argv.include?(\"--#{sym}\") }\nabort 'One of the following options is required: --url, --update, --version' unless ok","typeGuard":null,"tryCatchPattern":"begin\n  options = parser.results(argv)\nrescue OptParseValidator::NoRequiredOption => e\n  # e.message already lists every acceptable alternative; surface it verbatim\n  warn e.message\n  exit 64 # EX_USAGE\nend","preventionTips":["Standardize wrapper scripts so they always end in either a --url scan or an explicit --update/--version action","When building argv dynamically, assert the final command contains one of the allowed actions before exec","Keep the alternative list in sync when upgrading wpscan - re-read the error message, it enumerates current options"],"tags":["cli","option-parsing","ruby","wpscan","conditional-required"],"backgroundTag":"conditionally-required-cli-option","analyzedSha":"62c9cef471de90095f6b42245a11d0f8172d19c9","analyzedAt":"2026-08-21T17:10:47.902Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}