{"record":{"id":"8ad4124508caf4b1","repo":"puppetlabs/puppet","slug":"options-with-optional-arguments-are-not-supported","errorCode":null,"errorMessage":"Options with optional arguments are not supported","messagePattern":"Options with optional arguments are not supported","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/interface/option.rb","lineNumber":75,"sourceCode":"\n    # Now, infer the name from the options; we prefer the first long option as\n    # the name, rather than just the first option.\n    @name = optparse_to_name(@optparse.find do |a| a =~ /^--/ end || @optparse.first)\n    @aliases = @optparse.map { |o| optparse_to_name(o) }\n\n    # Do we take an argument?  If so, are we consistent about it, because\n    # incoherence here makes our life super-difficult, and we can more easily\n    # relax this rule later if we find a valid use case for it. --daniel 2011-03-30\n    @argument = @optparse.any? { |o| o =~ /[ =]/ }\n    if @argument and !@optparse.all? { |o| o =~ /[ =]/ } then\n      raise ArgumentError, _(\"Option %{name} is inconsistent about taking an argument\") % { name: @name }\n    end\n\n    # Is our argument optional?  The rules about consistency apply here, also,\n    # just like they do to taking arguments at all. --daniel 2011-03-30\n    @optional_argument = @optparse.any? { |o| o =~ /[ =]\\[/ }\n    if @optional_argument\n      raise ArgumentError, _(\"Options with optional arguments are not supported\")\n    end\n    if @optional_argument and !@optparse.all? { |o| o =~ /[ =]\\[/ } then\n      raise ArgumentError, _(\"Option %{name} is inconsistent about the argument being optional\") % { name: @name }\n    end\n  end\n\n  # to_s and optparse_to_name are roughly mirrored, because they are used to\n  # transform options to name symbols, and vice-versa.  This isn't a full\n  # bidirectional transformation though. --daniel 2011-04-07\n\n  def to_s\n    @name.to_s.tr('_', '-')\n  end\n\n  # @api private\n  def optparse_to_optionname(declaration)\n    found = declaration.match(/^-+(?:\\[no-\\])?([^ =]+)/)\n    unless found","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/interface/option.rb#L57-L93","documentation":"Error \"Options with optional arguments are not supported\" thrown in puppetlabs/puppet.","triggerScenarios":"Thrown at lib/puppet/interface/option.rb:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}