Class: Cliqr::Config::Command Private
- Inherits:
-
Action
- Object
- Base
- EventBased
- Named
- OptionBased
- Action
- Cliqr::Config::Command
- Defined in:
- lib/cliqr/config/command.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Configuration setting for a command
Instance Attribute Summary collapse
-
#color ⇒ Symbol
private
Enable or disable colors in a command handler (default enabled).
-
#shell ⇒ Cliqr::Command::ShellConfig
private
Configuration for the shell for this command.
-
#version ⇒ Stirng
private
Version tag for this configuration.
Attributes inherited from Action
#actions, #arguments, #handler, #help, #parent
Attributes inherited from OptionBased
Attributes inherited from Named
Attributes inherited from EventBased
Instance Method Summary collapse
-
#color? ⇒ Boolean
private
Check if colors are enabled for this setting.
-
#finalize ⇒ Cliqr::Config::Command
private
Finalize config by adding default values for unset values.
-
#initialize ⇒ Command
constructor
private
New config instance with all attributes set as UNSET.
-
#set_config(name, value, *args, &block) ⇒ Object
private
Set value for a config option.
-
#setup_defaults ⇒ Cliqr::Config::Command
private
Set up default attributes for this configuration.
-
#shell? ⇒ Boolean
private
Check if this configuration has shell action enabled.
-
#version? ⇒ Boolean
private
Check if version is enabled for this command.
Methods inherited from Action
#action, #action?, #actions?, #arguments?, #command, #help?, #parent?, #root, #root?
Methods inherited from OptionBased
Methods inherited from Named
Methods inherited from EventBased
Methods inherited from Base
Methods included from Validation
#errors, included, #read_attributes, #valid?, #validate, #validations
Methods included from DSL
Constructor Details
#initialize ⇒ Command
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
New config instance with all attributes set as UNSET
33 34 35 36 37 38 39 |
# File 'lib/cliqr/config/command.rb', line 33 def initialize super @shell = UNSET @version = UNSET @color = UNSET end |
Instance Attribute Details
#color ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Enable or disable colors in a command handler (default enabled)
28 29 30 |
# File 'lib/cliqr/config/command.rb', line 28 def color @color end |
#shell ⇒ Cliqr::Command::ShellConfig
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configuration for the shell for this command
16 17 18 |
# File 'lib/cliqr/config/command.rb', line 16 def shell @shell end |
#version ⇒ Stirng
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Version tag for this configuration
23 24 25 |
# File 'lib/cliqr/config/command.rb', line 23 def version @version end |
Instance Method Details
#color? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if colors are enabled for this setting
98 99 100 |
# File 'lib/cliqr/config/command.rb', line 98 def color? @color == Cliqr::Config::ENABLE_CONFIG end |
#finalize ⇒ Cliqr::Config::Command
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finalize config by adding default values for unset values
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cliqr/config/command.rb', line 44 def finalize super @color = Config.get_if_unset(@color, Cliqr::Config::ENABLE_CONFIG) @shell = Config.get_if_unset(@shell, proc { Cliqr::Util.build_shell_config(self) }) @version = Config.get_if_unset(@version, nil) # disable colors in shell if colors are disabled here @shell.disable_color unless color? self end |
#set_config(name, value, *args, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set value for a config option
64 65 66 67 68 69 70 71 |
# File 'lib/cliqr/config/command.rb', line 64 def set_config(name, value, *args, &block) case name when :shell handle_shell(value, &block) else super end end |
#setup_defaults ⇒ Cliqr::Config::Command
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set up default attributes for this configuration
76 77 78 79 80 81 |
# File 'lib/cliqr/config/command.rb', line 76 def setup_defaults super add_shell add_version end |
#shell? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if this configuration has shell action enabled
86 87 88 |
# File 'lib/cliqr/config/command.rb', line 86 def shell? @shell.enabled? end |
#version? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if version is enabled for this command
93 94 95 |
# File 'lib/cliqr/config/command.rb', line 93 def version? !@version.nil? end |