Class: CLI::Kit::Args::Definition::Flag
- Inherits:
-
Object
- Object
- CLI::Kit::Args::Definition::Flag
- Includes:
- OptBase
- Defined in:
- lib/cli/kit/args/definition.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#long ⇒ Object
readonly
: String?.
-
#short ⇒ Object
readonly
: String?.
Attributes included from OptBase
Instance Method Summary collapse
-
#as_written_by_user ⇒ Object
: -> String.
-
#initialize(name:, short: nil, long: nil, desc: nil) ⇒ Flag
constructor
: (name: Symbol, ?short: String?, ?long: String?, ?desc: String?) -> void.
Constructor Details
#initialize(name:, short: nil, long: nil, desc: nil) ⇒ Flag
: (name: Symbol, ?short: String?, ?long: String?, ?desc: String?) -> void
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/cli/kit/args/definition.rb', line 118 def initialize(name:, short: nil, long: nil, desc: nil) if long&.start_with?('-') || short&.start_with?('-') raise(ArgumentError, 'invalid - prefix') end @name = name @short = short @long = long @desc = desc end |
Instance Attribute Details
#long ⇒ Object (readonly)
: String?
110 111 112 |
# File 'lib/cli/kit/args/definition.rb', line 110 def long @long end |
#short ⇒ Object (readonly)
: String?
107 108 109 |
# File 'lib/cli/kit/args/definition.rb', line 107 def short @short end |
Instance Method Details
#as_written_by_user ⇒ Object
: -> String
113 114 115 |
# File 'lib/cli/kit/args/definition.rb', line 113 def as_written_by_user long ? "--#{long}" : "-#{short}" end |