Module: Tapioca::ConfigHelper

Extended by:
T::Helpers, T::Sig
Included in:
Cli
Defined in:
lib/tapioca/helpers/config_helper.rb

Defined Under Namespace

Classes: ConfigError, ConfigErrorMessagePart

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#command_nameObject (readonly)

Returns the value of attribute command_name.



12
13
14
# File 'lib/tapioca/helpers/config_helper.rb', line 12

def command_name
  @command_name
end

#defaultsObject (readonly)

Returns the value of attribute defaults.



15
16
17
# File 'lib/tapioca/helpers/config_helper.rb', line 15

def defaults
  @defaults
end

Instance Method Details

#initialize(args = [], local_options = {}, config = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tapioca/helpers/config_helper.rb', line 18

def initialize(args = [], local_options = {}, config = {})
  # Store current command
  command = config[:current_command]
  command_options = config[:command_options]
  @command_name = T.let(command.name, String)
  @merged_options = T.let(nil, T.nilable(Thor::CoreExt::HashWithIndifferentAccess))
  @defaults = T.let(Thor::CoreExt::HashWithIndifferentAccess.new, Thor::CoreExt::HashWithIndifferentAccess)

  # Filter command options unless we are handling the help command.
  # This is so that the defaults are printed
  filter_defaults(command_options) unless command_name == "help"

  super
end

#optionsObject



34
35
36
37
38
39
40
41
# File 'lib/tapioca/helpers/config_helper.rb', line 34

def options
  @merged_options ||= begin
    original_options = super
    config_options = config_options(original_options)

    merge_options(defaults, config_options, original_options)
  end
end