Class: OptparseLite::SubCommands

Inherits:
Array
  • Object
show all
Includes:
Lingual
Defined in:
lib/optparse-lite.rb

Instance Method Summary collapse

Methods included from Lingual

#methodize, #oxford_comma

Constructor Details

#initialize(parent_cmd, subcommand_names) ⇒ SubCommands

Returns a new instance of SubCommands.



598
599
600
601
602
603
604
605
606
607
608
609
# File 'lib/optparse-lite.rb', line 598

def initialize parent_cmd, subcommand_names
  @command = parent_cmd
  method_name = parent_cmd.method_name
  app_spec = parent_cmd.spec
  arr = subcommand_names.nil? ? [] : subcommand_names.map do |name|
    cmd = app_spec.get_command "#{method_name}_#{methodize(name)}"
    cmd.given_name = name
    cmd.parent = parent_cmd
    cmd
  end
  super(arr)
end

Instance Method Details

#find_all_local(local_name) ⇒ Object



611
612
613
614
615
616
617
618
# File 'lib/optparse-lite.rb', line 611

def find_all_local local_name
  re = /^#{Regexp.escape(local_name)}/
  these = select do |x|
    return [x] if x.given_name.to_s == local_name
    re =~ x.given_name.to_s
  end
  these
end

#pretty_fullObject



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

def pretty_full; @command.pretty_full end