Class: Hanami::CLI::Option Private
- Inherits:
-
Object
- Object
- Hanami::CLI::Option
- Defined in:
- lib/hanami/cli/option.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.
Command line option
Direct Known Subclasses
Instance Attribute Summary collapse
- #name ⇒ Object readonly private
- #options ⇒ Object readonly private
Instance Method Summary collapse
- #aliases ⇒ Object private
- #argument? ⇒ Boolean private
- #array? ⇒ Boolean private
- #boolean? ⇒ Boolean private
- #default ⇒ Object private
- #desc ⇒ Object private
- #description_name ⇒ Object private
-
#initialize(name, options = {}) ⇒ Option
constructor
private
A new instance of Option.
-
#parser_options ⇒ Object
private
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
- #required? ⇒ Boolean private
- #type ⇒ Object private
- #values ⇒ Object private
Constructor Details
#initialize(name, options = {}) ⇒ Option
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.
Returns a new instance of Option.
20 21 22 23 |
# File 'lib/hanami/cli/option.rb', line 20 def initialize(name, = {}) @name = name @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
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.
12 13 14 |
# File 'lib/hanami/cli/option.rb', line 12 def name @name end |
#options ⇒ Object (readonly)
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.
16 17 18 |
# File 'lib/hanami/cli/option.rb', line 16 def @options end |
Instance Method Details
#aliases ⇒ 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.
27 28 29 |
# File 'lib/hanami/cli/option.rb', line 27 def aliases [:aliases] || [] end |
#argument? ⇒ 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.
82 83 84 |
# File 'lib/hanami/cli/option.rb', line 82 def argument? false end |
#array? ⇒ 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.
64 65 66 |
# File 'lib/hanami/cli/option.rb', line 64 def array? type == :array end |
#boolean? ⇒ 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.
58 59 60 |
# File 'lib/hanami/cli/option.rb', line 58 def boolean? type == :boolean end |
#default ⇒ 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.
70 71 72 |
# File 'lib/hanami/cli/option.rb', line 70 def default [:default] end |
#desc ⇒ 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.
33 34 35 36 |
# File 'lib/hanami/cli/option.rb', line 33 def desc desc = [:desc] values ? "#{desc}: (#{values.join('/')})" : desc end |
#description_name ⇒ 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.
76 77 78 |
# File 'lib/hanami/cli/option.rb', line 76 def description_name [:label] || name.upcase end |
#parser_options ⇒ 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.
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/hanami/cli/option.rb', line 91 def dasherized_name = Hanami::Utils::String.dasherize(name) = [] if boolean? << "--[no-]#{dasherized_name}" else << "--#{dasherized_name}=#{name}" << "--#{dasherized_name} #{name}" end << Array if array? << values if values .unshift(alias_name) unless alias_name.nil? << desc if desc end |
#required? ⇒ 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.
40 41 42 |
# File 'lib/hanami/cli/option.rb', line 40 def required? [:required] end |
#type ⇒ 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.
46 47 48 |
# File 'lib/hanami/cli/option.rb', line 46 def type [:type] end |
#values ⇒ 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.
52 53 54 |
# File 'lib/hanami/cli/option.rb', line 52 def values [:values] end |