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
11 12 13 |
# File 'lib/cl/help/usage.rb', line 11 def executable ctx.name end |
#format ⇒ Object
4 5 6 7 8 9 |
# File 'lib/cl/help/usage.rb', line 4 def format usage = [executable, name] usage += cmd.args.map(&:to_s) # { |arg| "[#{arg}]" } usage << '[options]' if opts? usage.join(' ') end |
#name ⇒ Object
15 16 17 |
# File 'lib/cl/help/usage.rb', line 15 def name cmd.registry_key.to_s.gsub(':', ' ') end |
#opts? ⇒ Boolean
19 20 21 |
# File 'lib/cl/help/usage.rb', line 19 def opts? cmd.opts.any? end |