class SubCmdOptParser::OptionParserForSubCmd

Attributes

description[RW]
example[W]
subcommand_name[RW]
summary[RW]
usage[W]

Public Class Methods

new(subcmd, description, width, indent) click to toggle source
Calls superclass method
# File lib/subcommand_optparse.rb, line 13
def initialize(subcmd, description, width, indent)
  @subcommand_name = subcmd
  @description = description
  @summary = nil
  super(nil, width, indent)
end

Public Instance Methods

banner() click to toggle source
help() click to toggle source
# File lib/subcommand_optparse.rb, line 55
def help
  str_banner = "#{banner}".sub(/\n?\z/, "\n")
  str_summary =  summarize("")
  if str_summary.size > 0
    str_banner << "\nOptions:\n"
  end
  str_banner + str_summary
end
Also aliased as: to_s
to_s()
Alias for: help
usage() click to toggle source
# File lib/subcommand_optparse.rb, line 20
def usage
  usage_str = "Usage: "
  if @usage
    @usage.each_line.with_index do |line, ind|
      usage_str << "       " if ind > 0
      usage_str << line.sub(/\n?\z/, "\n")
    end
  else
    usage_str << "#{program_name} #{@subcommand_name || '<command>'} [options]\n"
  end
  usage_str
end