Class: OptimistXL::SubcommandParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/optimist_xl.rb

Constant Summary

Constants inherited from Parser

Parser::DEFAULT_SETTINGS

Instance Attribute Summary collapse

Attributes inherited from Parser

#ignore_invalid_options, #leftovers, #specs

Instance Method Summary collapse

Methods inherited from Parser

#banner, #conflicts, #depends, #die, #educate, #educate_on_error, #opt, #parse, #parse_base, register, registry_getopttype, #stop_on, #stop_on_unknown, #subcmd, #subcommands, #synopsis, #usage, #version, #width, #wrap

Constructor Details

#initialize(name, desc, *a, &b) ⇒ SubcommandParser

Returns a new instance of SubcommandParser.



768
769
770
771
772
# File 'lib/optimist_xl.rb', line 768

def initialize(name, desc, *a, &b)
  super(a, &b)
  @name = name
  @desc = desc
end

Instance Attribute Details

#descObject (readonly)

Returns the value of attribute desc.



767
768
769
# File 'lib/optimist_xl.rb', line 767

def desc
  @desc
end

#nameObject (readonly)

Returns the value of attribute name.



767
768
769
# File 'lib/optimist_xl.rb', line 767

def name
  @name
end

Instance Method Details

#default_bannerObject



779
780
781
782
783
784
785
786
787
# File 'lib/optimist_xl.rb', line 779

def default_banner()
  command_name = File.basename($0).gsub(/\.[^.]+$/, '')
  bannertext = ''
  bannertext << "Usage: #{command_name} #{@name} #{@usage}\n\n" if @usage
  bannertext << "#{@synopsis}\n\n" if @synopsis
  bannertext << "#{desc}\n\n" if @desc
  bannertext << "Options:\n"
  return bannertext
end

#subcommand_nameObject

alias to make referencing more obvious.



775
776
777
# File 'lib/optimist_xl.rb', line 775

def subcommand_name
  @name
end