Class: CommandLine::SubCommands::ListCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/git/contest/command_line/sub_commands/list_command.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #input_stream, #opt_parser, #options, #terminal, #tokens

Instance Method Summary collapse

Methods inherited from Command

#init

Constructor Details

#initialize(new_args, new_input_stream = STDIN) ⇒ ListCommand

Returns a new instance of ListCommand.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/git/contest/command_line/sub_commands/list_command.rb', line 15

def initialize(new_args, new_input_stream = STDIN)
  super

  Contest::Driver::Utils.load_plugins

  $config = get_config() || {}
  $sites  = {}
  if $config.has_key? 'sites'
    $sites = $config["sites"]
  end
end

Instance Method Details

#define_optionsObject



27
28
# File 'lib/git/contest/command_line/sub_commands/list_command.rb', line 27

def define_options
end

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/git/contest/command_line/sub_commands/list_command.rb', line 33

def run
  sub_commands = %w(sites drivers)

  type = next_token

  case type
  when "drivers"
    # show all drivers
    puts "#"
    puts "# Available Drivers"
    puts "#"
    puts ""
    drivers = Contest::Driver::Utils.get_all_drivers
    drivers.each {|driver_info|
      puts "  #{driver_info[:class_name]}"
      puts "    #{driver_info[:site_info][:desc]}"
      puts ""
    }
  when "sites"
    # show all sites
    $sites.keys.each do |site_name|
      puts "# #{site_name}"
      keys = ["driver", "user"]
      keys.each {|key| puts "    %-8s: %s" % [ key, $sites[site_name][key] ] }
      puts " \n"
    end
  else
    usage
  end

end

#set_default_optionsObject



30
31
# File 'lib/git/contest/command_line/sub_commands/list_command.rb', line 30

def set_default_options
end