# File lib/operator.rb, line 32
    def build_args project, method, args
      specs = @operations[method][:args_spec]
      command = "command '#{method_to_op method}'"

      if specs.empty? && args == ["<options>"]
        die_with_completions project, method, nil
      end

      built_args = specs.map do |spec|
        optional = spec.to_s =~ /^maybe_/
        spec = spec.to_s.gsub(/^maybe_/, "").intern # :(
        val = args.shift

        case val
        when nil
          next if optional
          specname = spec.to_s.gsub("_", " ")
          article = specname =~ /^[aeiou]/ ? "an" : "a"
          raise Error, "#{command} requires #{article} #{specname}"
        when "<options>"
          die_with_completions project, method, spec
        end

        case spec
        when :issue, :open_issue, :unstarted_issue, :started_issue, :assigned_issue
          ## issue completion sticks the title on there, so this will strip it off
          valr = val.sub(/\A(\w+-\d+)_.*$/,'\1')
          issues = project.issues_for valr
          case issues.size
          when 0; raise Error, "no issue with name #{val.inspect}"
          when 1; issues.first
          else
            raise Error, "multiple issues matching name #{val.inspect}"
          end
        when :release, :unreleased_release
          if val == "unassigned"
            :unassigned
          else
            project.release_for(val) or raise Error, "no release with name #{val}"
          end
        when :component
          project.component_for(val) or raise Error, "no component with name #{val}" if val
        else
          val # no translation for other types
        end
      end

      raise Error, "too many arguments for #{command}" unless args.empty?
      built_args
    end