Module: ThorAddons::Options

Defined in:
lib/thor-addons/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_command_nameObject (readonly)

Returns the value of attribute current_command_name.



5
6
7
# File 'lib/thor-addons/options.rb', line 5

def current_command_name
  @current_command_name
end

#defaultsObject (readonly)

Returns the value of attribute defaults.



5
6
7
# File 'lib/thor-addons/options.rb', line 5

def defaults
  @defaults
end

#invocationsObject (readonly)

Returns the value of attribute invocations.



5
6
7
# File 'lib/thor-addons/options.rb', line 5

def invocations
  @invocations
end

Instance Method Details

#envs_aliasesObject



26
27
28
# File 'lib/thor-addons/options.rb', line 26

def envs_aliases
  {}
end

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



7
8
9
10
11
12
13
14
15
16
# File 'lib/thor-addons/options.rb', line 7

def initialize(args = [], local_options = {}, config = {})
  @defaults = Helpers::Defaults.load(self.class, config.dup)
  @invocations = config[:invocations]

  if config[:current_command].respond_to?(:name)
    @current_command_name = config[:current_command].name
  end

  super(args, local_options, config)
end

#optionsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/thor-addons/options.rb', line 30

def options
  original = Helpers::OptionsHash.new(super)

  return original unless with_env? || with_config_file?

  new_options = Helpers::Defaults.remove(original, defaults)
  update_options!(new_options, original[:config_file])

  opts = Helpers::OptionsHash.new(
    Helpers::Defaults.add(new_options, defaults)
  )

  validate_options(opts)
end

#with_config_file?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/thor-addons/options.rb', line 22

def with_config_file?
  true
end

#with_env?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/thor-addons/options.rb', line 18

def with_env?
  true
end