Module: Branchtree

Defined in:
lib/branchtree.rb,
lib/branchtree/tree.rb,
lib/branchtree/branch.rb,
lib/branchtree/version.rb,
lib/branchtree/situation.rb,
lib/branchtree/commands/edit.rb,
lib/branchtree/commands/help.rb,
lib/branchtree/commands/show.rb,
lib/branchtree/commands/common.rb,
lib/branchtree/commands/parent.rb,
lib/branchtree/commands/update.rb,
lib/branchtree/commands/checkout.rb

Defined Under Namespace

Modules: Commands, Context Classes: Branch, Situation, Tree

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.execute(argv) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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