Class: Toolshed::Commands::CheckoutBranch

Inherits:
Object
  • Object
show all
Defined in:
lib/toolshed/commands/checkout_branch.rb

Instance Method Summary collapse

Instance Method Details

#execute(args, options = {}) ⇒ Object



4
5
6
7
8
# File 'lib/toolshed/commands/checkout_branch.rb', line 4

def execute(args, options = {})
  branch_name = read_user_input("Ticket ID or Branch Name:", options)
  branch_name = Toolshed::Git::Base.checkout(branch_name)
  puts "Switched to '#{branch_name}'"
end

#read_user_input(message, options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/toolshed/commands/checkout_branch.rb', line 10

def read_user_input(message, options)
  return options[:branch_name] if (options.has_key?(:branch_name))

  puts message
  value = $stdin.gets.chomp

  until (!value.empty?)
    puts "Branch name cannot be empty"
    puts message
    value = $stdin.gets.chomp
  end

  value
end