Class: Cl::Help::Usage
- Inherits:
-
Struct
- Object
- Struct
- Cl::Help::Usage
- Defined in:
- lib/cl/help/usage.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#ctx ⇒ Object
Returns the value of attribute ctx.
Instance Method Summary collapse
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd
3 4 5 |
# File 'lib/cl/help/usage.rb', line 3 def cmd @cmd end |
#ctx ⇒ Object
Returns the value of attribute ctx
3 4 5 |
# File 'lib/cl/help/usage.rb', line 3 def ctx @ctx end |
Instance Method Details
#executable ⇒ Object
17 18 19 |
# File 'lib/cl/help/usage.rb', line 17 def executable ctx.name end |
#format ⇒ Object
4 5 6 7 8 |
# File 'lib/cl/help/usage.rb', line 4 def format cmd.registry_keys.map do |key| line(key) end end |
#line(key) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/cl/help/usage.rb', line 10 def line(key) usage = [executable, key.to_s.gsub(':', ' ')] usage += cmd.args.map(&:to_s) # { |arg| "[#{arg}]" } usage << '[options]' if opts? usage.join(' ') end |
#opts? ⇒ Boolean
21 22 23 |
# File 'lib/cl/help/usage.rb', line 21 def opts? cmd.opts.any? end |