Module: KnifeAttribute::CommonOptions

Included in:
Node::NodeAttributeDelete, Node::NodeAttributeGet, Node::NodeAttributeSet
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
11
# 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',
      default: 'normal',
      description: "Attribute type to set, one of: #{KnifeAttribute::ATTRIBUTE_TYPES} (default: 'normal')"
  end
end

Instance Method Details

#check_typeObject



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

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