Module: Mwc::Utils::Command::ClassMethods
- Defined in:
- lib/mwc/utils/command.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#add_option(name, options = {}) ⇒ Object
private
Add command options.
-
#description(desc = nil) ⇒ Object
private
Get or set command description.
-
#display? ⇒ TrueClass, FalseClass
private
The command should display or not.
-
#display_on(&block) ⇒ Object
private
Define the command display policy.
-
#name(name = nil) ⇒ Object
private
Get or set command name.
-
#options ⇒ Object
private
The command options.
-
#source_root ⇒ String
private
The thor template source root.
-
#usage(usage = nil) ⇒ Object
private
Set command usage.
Instance Method Details
#add_option(name, 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.
Add command options
103 104 105 106 |
# File 'lib/mwc/utils/command.rb', line 103 def add_option(name, = {}) @options ||= [] @options.push([name, ]) end |
#description(desc = nil) ⇒ 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.
Get or set command description
46 47 48 49 50 |
# File 'lib/mwc/utils/command.rb', line 46 def description(desc = nil) return @description || name if desc.nil? @description = desc end |
#display? ⇒ TrueClass, FalseClass
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.
The command should display or not
58 59 60 61 62 |
# File 'lib/mwc/utils/command.rb', line 58 def display? return true if @display.nil? @display.call end |
#display_on(&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.
Define the command display policy
70 71 72 73 74 |
# File 'lib/mwc/utils/command.rb', line 70 def display_on(&block) return unless block_given? @display = block end |
#name(name = nil) ⇒ 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.
Get or set command name
22 23 24 25 26 |
# File 'lib/mwc/utils/command.rb', line 22 def name(name = nil) return @name || self.name.split('::').last.downcase if name.nil? @name = name end |
#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.
The command options
92 93 94 |
# File 'lib/mwc/utils/command.rb', line 92 def @options ||= [] end |
#source_root ⇒ String
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.
The thor template source root
84 85 86 |
# File 'lib/mwc/utils/command.rb', line 84 def source_root Mwc.source_root end |
#usage(usage = nil) ⇒ 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 command usage
34 35 36 37 38 |
# File 'lib/mwc/utils/command.rb', line 34 def usage(usage = nil) return @usage || name if usage.nil? @usage = usage end |