Sha256: 90004b9590743e667acb4d9ddd6fbbc1cfdc66720a8449a767946c95204d2c5d

Contents?: true

Size: 899 Bytes

Versions: 1

Compression:

Stored size: 899 Bytes

Contents

module Heirloom
  module CLI
    module Shared

      def 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!

        missing_opts.each {|missing_opt| logger.error missing_opt}

        missing_opts.empty?
      end

      def load_config(args)
        opts = args[:opts]
        logger = args[:logger]
        config = Config.new :logger => logger
        config.access_key = opts[:key] if opts[:key_given]
        config.secret_key = opts[:secret] if opts[:secret_given]
        config
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.4.0 lib/heirloom/cli/shared.rb