Class: SubCmdOptParser::OptionParserForSubCmd

Inherits:
OptionParser
  • Object
show all
Defined in:
lib/subcommand_optparse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subcmd, description, width, indent) ⇒ OptionParserForSubCmd

Returns a new instance of OptionParserForSubCmd.



10
11
12
13
14
# File 'lib/subcommand_optparse.rb', line 10

def initialize(subcmd, description, width, indent)
  @subcommand_name = subcmd
  @description = description
  super(nil, width, indent)
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/subcommand_optparse.rb', line 8

def description
  @description
end

#subcommand_nameObject

Returns the value of attribute subcommand_name.



7
8
9
# File 'lib/subcommand_optparse.rb', line 7

def subcommand_name
  @subcommand_name
end

Instance Method Details



16
17
18
19
20
21
22
23
24
25
# File 'lib/subcommand_optparse.rb', line 16

def banner
  unless @banner
    @banner = "Usage: #{program_name} #{@subcommand_name || '<command>'} [options]"
    if @description
      @banner << "\n\n#{@description}"
    end
    visit(:add_banner, @banner)
  end
  @banner
end