Class: Toolshed::Commands::DeleteBranch

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

Instance Method Summary collapse

Instance Method Details

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



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

def execute(args, options = {})
  branch_name = read_user_input("Ticket ID or branch name:", options)
  branch_name = Toolshed::Git::Base.delete(branch_name)
  puts "#{branch_name} has been deleted"
  return
end

#read_user_input(message, options) ⇒ Object



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

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