Class: Benry::CmdApp::ActionMetadata
- Inherits:
-
BaseMetadata
- Object
- BaseMetadata
- Benry::CmdApp::ActionMetadata
- Defined in:
- lib/benry/cmdapp.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#meth ⇒ Object
readonly
Returns the value of attribute meth.
-
#postamble ⇒ Object
readonly
Returns the value of attribute postamble.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Attributes inherited from BaseMetadata
#desc, #hidden, #important, #name, #tag
Instance Method Summary collapse
- #alias? ⇒ Boolean
- #hidden? ⇒ Boolean
-
#initialize(name, desc, schema, klass, meth, usage: nil, detail: nil, description: nil, postamble: nil, tag: nil, important: nil, hidden: nil) ⇒ ActionMetadata
constructor
A new instance of ActionMetadata.
- #option_empty?(all: false) ⇒ Boolean
- #option_help(format, all: false) ⇒ Object
- #parse_options(args) ⇒ Object
Constructor Details
#initialize(name, desc, schema, klass, meth, usage: nil, detail: nil, description: nil, postamble: nil, tag: nil, important: nil, hidden: nil) ⇒ ActionMetadata
Returns a new instance of ActionMetadata.
271 272 273 274 275 276 277 278 279 280 |
# File 'lib/benry/cmdapp.rb', line 271 def initialize(name, desc, schema, klass, meth, usage: nil, detail: nil, description: nil, postamble: nil, tag: nil, important: nil, hidden: nil) super(name, desc, tag: tag, important: important, hidden: hidden) @schema = schema @klass = klass @meth = meth @usage = usage if nil != usage @detail = detail if nil != detail @description = description if nil != description @postamble = postamble if nil != postamble end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
282 283 284 |
# File 'lib/benry/cmdapp.rb', line 282 def description @description end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
282 283 284 |
# File 'lib/benry/cmdapp.rb', line 282 def detail @detail end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
282 283 284 |
# File 'lib/benry/cmdapp.rb', line 282 def klass @klass end |
#meth ⇒ Object (readonly)
Returns the value of attribute meth.
282 283 284 |
# File 'lib/benry/cmdapp.rb', line 282 def meth @meth end |
#postamble ⇒ Object (readonly)
Returns the value of attribute postamble.
282 283 284 |
# File 'lib/benry/cmdapp.rb', line 282 def postamble @postamble end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
282 283 284 |
# File 'lib/benry/cmdapp.rb', line 282 def schema @schema end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
282 283 284 |
# File 'lib/benry/cmdapp.rb', line 282 def usage @usage end |
Instance Method Details
#alias? ⇒ Boolean
311 312 313 314 |
# File 'lib/benry/cmdapp.rb', line 311 def alias?() #; [!c1eq3] returns false which means that this is not an alias metadata. return false end |
#hidden? ⇒ Boolean
284 285 286 287 288 289 |
# File 'lib/benry/cmdapp.rb', line 284 def hidden?() #; [!stied] returns true/false if `hidden:` kwarg provided. #; [!eumhz] returns true/false if method is private or not. return @hidden if @hidden != nil return ! @klass.method_defined?(@meth) end |
#option_empty?(all: false) ⇒ Boolean
291 292 293 294 295 296 |
# File 'lib/benry/cmdapp.rb', line 291 def option_empty?(all: false) #; [!14xgg] returns true if the action has no options. #; [!dbtht] returns false if the action has at least one option. #; [!wa315] considers hidden options if `all: true` passed. return @schema.empty?(all: all) end |
#option_help(format, all: false) ⇒ Object
298 299 300 301 302 |
# File 'lib/benry/cmdapp.rb', line 298 def option_help(format, all: false) #; [!bpkwn] returns help message string of the action. #; [!76hni] includes hidden options in help message if `all:` is truthy. return @schema.option_help(format, all: all) end |
#parse_options(args) ⇒ Object
304 305 306 307 308 309 |
# File 'lib/benry/cmdapp.rb', line 304 def (args) #; [!gilca] returns parsed options. #; [!v34yk] raises OptionError if option has error. parser = ACTION_OPTION_PARSER_CLASS.new(@schema) return parser.parse(args, all: true) # raises error if invalid option given end |