Module: KnifeAttribute::CommonOptions

Defined in:
lib/knife-attribute/common_options.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/knife-attribute/common_options.rb', line 3

def self.included(base)
  base.class_eval do
    option :attribute_type,
      short: '-t TYPE',
      long: '--type TYPE',
      description: "Attribute type, one of: #{attribute_type_map.keys.map(&:to_s)} (default: '#{default_attribute_type.to_s}')"
  end
end

Instance Method Details

#check_typeObject



12
13
14
15
16
17
# File 'lib/knife-attribute/common_options.rb', line 12

def check_type
  if config[:attribute_type] and !attribute_type_map.keys.include?(config[:attribute_type].to_sym)
    show_usage
    ui.fatal("Invalid attribute type: '#{config[:attribute_type]}'")
  end
end