Module: ThorAddons::Options
- Defined in:
- lib/thor-addons/options.rb
Instance Attribute Summary collapse
-
#current_command_name ⇒ Object
readonly
Returns the value of attribute current_command_name.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#invocations ⇒ Object
readonly
Returns the value of attribute invocations.
Instance Method Summary collapse
- #envs_aliases ⇒ Object
- #initialize(args = [], local_options = {}, config = {}) ⇒ Object
- #options ⇒ Object
- #with_config_file? ⇒ Boolean
- #with_env? ⇒ Boolean
Instance Attribute Details
#current_command_name ⇒ Object (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 |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
5 6 7 |
# File 'lib/thor-addons/options.rb', line 5 def defaults @defaults end |
#invocations ⇒ Object (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_aliases ⇒ Object
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 = [], = {}, 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, , config) end |
#options ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/thor-addons/options.rb', line 30 def original = Helpers::OptionsHash.new(super) return original unless with_env? || with_config_file? = Helpers::Defaults.remove(original, defaults) (, original[:config_file]) opts = Helpers::OptionsHash.new( Helpers::Defaults.add(, defaults) ) (opts) end |
#with_config_file? ⇒ Boolean
22 23 24 |
# File 'lib/thor-addons/options.rb', line 22 def with_config_file? true end |
#with_env? ⇒ Boolean
18 19 20 |
# File 'lib/thor-addons/options.rb', line 18 def with_env? true end |