Class: Argy::Help
- Inherits:
-
Object
- Object
- Argy::Help
- Defined in:
- lib/argy/help.rb
Instance Method Summary collapse
- #entry(name, desc: nil, required: false, default: nil) ⇒ Object
-
#initialize(parser, column: 30, color: $stdout.tty?) ⇒ Help
constructor
A new instance of Help.
- #section(title) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(parser, column: 30, color: $stdout.tty?) ⇒ Help
Returns a new instance of Help.
3 4 5 6 7 |
# File 'lib/argy/help.rb', line 3 def initialize(parser, column: 30, color: $stdout.tty?) @parser = parser @column = column @color = color end |
Instance Method Details
#entry(name, desc: nil, required: false, default: nil) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/argy/help.rb', line 26 def entry(name, desc: nil, required: false, default: nil) out = " #{name.ljust(column)}" out += dim("#{desc} ") if desc out += dim("(required) ") if required out += dim("[default: #{default.inspect}]") if default out.rstrip end |
#section(title) ⇒ Object
22 23 24 |
# File 'lib/argy/help.rb', line 22 def section(title) bold "\n#{title}" end |
#to_s ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/argy/help.rb', line 9 def to_s out = [] description(out) usage(out) examples(out) arguments(out) (out) flags(out) out.join("\n") + "\n" end |