Module: OptparseLite::HelpHelper

Included in:
Command, Dispatcher, Help, OptParser, OptParser::Response, OptParser::UnparsedParamters, ServiceObject
Defined in:
lib/optparse-lite.rb,
lib/optparse-lite.rb

Instance Method Summary collapse

Instance Method Details

#cmd(str) ⇒ Object



325
# File 'lib/optparse-lite.rb', line 325

def cmd(str); str end

#hdr(str) ⇒ Object Also known as: code

Codes = :green=>‘32’, :yellow=>‘33’, :bold=>‘1’, :blink=>5



322
# File 'lib/optparse-lite.rb', line 322

def hdr(str); "\e[32;m#{str}\e[0m" end

#help_requested?(argv) ⇒ Boolean

Returns:

  • (Boolean)


313
314
315
# File 'lib/optparse-lite.rb', line 313

def help_requested?(argv)
  ['-h','--help','-?','help'].include? argv[0]
end

#looks_like_header?(line) ⇒ Boolean

Not sure about this. ‘lines like this:’ usually aren’t headers but maybe ‘Lines Like This:’ are. are ‘Lines like this:’ ?

Returns:

  • (Boolean)


318
319
320
# File 'lib/optparse-lite.rb', line 318

def looks_like_header? line
  /\A[A-Z0-9][A-Za-z]*(?:\s[A-Za-z0-9]*)*:\s*\Z/ =~ line
end

#prefixObject



323
# File 'lib/optparse-lite.rb', line 323

def prefix; "#{spec.invocation_name}: " end

#txt(str) ⇒ Object



324
# File 'lib/optparse-lite.rb', line 324

def txt(str); str end