Sha256: 0cf6a3a61a7d30d23abc38b40d25d4d127a913d5cb08ce93f248cf5e2b148a5e

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

module Heirloom
  module CLI
    module Shared

      def self.valid_options?(args)
        provided = args[:provided]
        required = args[:required]
        logger = args[:logger]

        missing_opts = required.map do |opt|
          case provided[opt]
          when nil
            "Option '#{opt} (-#{opt[0]})' required but not specified."
          when []
            "Option '#{opt} (-#{opt[0]})' required but not specified."
          end
        end

        missing_opts.compact!

        if missing_opts.any?
          missing_opts.each {|missing_opt| logger.error missing_opt}
        end

        missing_opts.any? ? false : true

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.3.0.rc1 lib/heirloom/cli/shared.rb