Class: SubCmdOptParser::OptionParserForSubCmd
- Inherits:
-
OptionParser
- Object
- OptionParser
- SubCmdOptParser::OptionParserForSubCmd
- Defined in:
- lib/subcommand_optparse.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#subcommand_name ⇒ Object
Returns the value of attribute subcommand_name.
Instance Method Summary collapse
- #banner ⇒ Object
-
#initialize(subcmd, description, width, indent) ⇒ OptionParserForSubCmd
constructor
A new instance of OptionParserForSubCmd.
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
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/subcommand_optparse.rb', line 8 def description @description end |
#subcommand_name ⇒ Object
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
#banner ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/subcommand_optparse.rb', line 16 def unless @banner @banner = "Usage: #{program_name} #{@subcommand_name || '<command>'} [options]" if @description @banner << "\n\n#{@description}" end visit(:add_banner, @banner) end @banner end |