class CommandLine::MainCommand

Attributes

sub_commands[R]

Public Class Methods

new(new_args, new_input_stream = STDIN) click to toggle source
Calls superclass method CommandLine::Command::new
# File lib/git/contest/command_line/main_command.rb, line 7
def initialize(new_args, new_input_stream = STDIN)
  super
  @sub_commands = SubCommands.all.freeze
end

Private Class Methods

usage() click to toggle source
# File lib/git/contest/command_line/main_command.rb, line 40
def self.usage
  puts "usage: git contest <subcommand>"
  puts ""
  puts "Available subcommands are:"
  puts "  %-12s Initialize a new git repo." % ["init"]
  puts "  %-12s Start a new feature branch." % ["start"]
  puts "  %-12s Finish a feature branch." % ["finish"]
  puts "  %-12s Submit a solution." % ["submit"]
  puts "  %-12s Show information (sites, drivers)." % ["list"]
  puts "  %-12s Get/Set a config value." % ["config"]
  puts ""
  puts "Try 'git contest <subcommand> help' for details."
end

Public Instance Methods

define_options() click to toggle source
# File lib/git/contest/command_line/main_command.rb, line 12
def define_options
end
run() click to toggle source
# File lib/git/contest/command_line/main_command.rb, line 18
def run
  if has_subcommand?
    command_name = args.shift
    call_subcommand command_name
  else
    MainCommand.usage
  end
end
set_default_options() click to toggle source
# File lib/git/contest/command_line/main_command.rb, line 15
def set_default_options
end

Private Instance Methods

call_subcommand(command_name) click to toggle source
# File lib/git/contest/command_line/main_command.rb, line 29
def call_subcommand(command_name)
  sub_command = to_command_class_sym(command_name)
  if sub_commands.include?(sub_command)
    cli = SubCommands.const_get(sub_command).new(args, input_stream)
    cli.init
    cli.run
  else
    SubCommands.usage
  end
end