Class: Thor::IncludedOption

Inherits:
SharedOption show all
Defined in:
lib/thor/parser/shared_option.rb

Constant Summary

Constants inherited from Option

Option::VALID_TYPES

Constants inherited from Argument

Argument::VALID_TYPES

Instance Attribute Summary collapse

Attributes inherited from SharedOption

#groups

Attributes inherited from Option

#aliases, #hide, #lazy_default

Attributes inherited from Argument

#banner, #complete, #default, #description, #enum, #name, #required, #type

Instance Method Summary collapse

Methods inherited from SharedOption

#initialize_options

Methods inherited from Option

alias_to_switch_name, #all_switch_names, #all_switch_tokens, #dasherize, #dasherized?, #human_name, #long_switch_names, #long_switch_tokens, parse, #short_switch_names, #short_switch_tokens, #switch_name, #undasherize, #usage, #validate!, #validate_default_type!

Methods inherited from Argument

#default_banner, #required?, #show_default?, #usage, #valid_type?, #validate!

Constructor Details

#initialize(option:, match:) ⇒ IncludedOption

Returns a new instance of IncludedOption.



86
87
88
89
# File 'lib/thor/parser/shared_option.rb', line 86

def initialize option:, match:
  super option.name, **option.initialize_options
  @match = match
end

Instance Attribute Details

#matchHash (readonly)

The match that resulted in this option getting included.

Returns:

  • (Hash)


83
84
85
# File 'lib/thor/parser/shared_option.rb', line 83

def match
  @match
end

Instance Method Details

#default_groupObject



110
111
112
113
114
# File 'lib/thor/parser/shared_option.rb', line 110

def default_group
  return nil unless match[:groups]
  
  match[:groups].map { |group| group.to_s.titleize }.join ' / '
end

#groupObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/thor/parser/shared_option.rb', line 93

def group
  case @group
  when false
    nil
  when String
    @group
  when nil
    default_group
  else
    logger.warn "Bad {Option#group}: #{ @group.inspect }",
      option: self
    nil
  end
end