module Branchtree

Constants

VERSION

Public Class Methods

execute(argv) click to toggle source
# File lib/branchtree.rb, line 6
def self.execute(argv)
  command_classes = {
    "show" => Branchtree::Commands::Show,
    "checkout" => Branchtree::Commands::Checkout,
    "update" => Branchtree::Commands::Update,
    "parent" => Branchtree::Commands::Parent,
    "edit" => Branchtree::Commands::Edit,
    "help" => Branchtree::Commands::Help,
    "-h" => Branchtree::Commands::Help,
    "--help" => Branchtree::Commands::Help,
  }

  command_name = argv.shift || "show"
  command_class = command_classes[command_name]
  unless command_class
    $stderr.puts "Unrecognized command: #{command_name}"
    $stderr.puts "Available commands: #{command_classes.keys.join(", ")}"
    exit 1
  end
  command = command_class.new
  command.parse(argv)
  command.execute
end