class Toolshed::Commands::DeleteBranch
Attributes
branch[RW]
Public Class Methods
cli_options()
click to toggle source
# File lib/toolshed/commands/delete_branch.rb, line 10 def self.cli_options { banner: 'Usage: delete_branch [options]', options: { branch_name: { short_on: '-b', } } } end
Public Instance Methods
confirm_delete()
click to toggle source
# File lib/toolshed/commands/delete_branch.rb, line 47 def confirm_delete choices = "yn" answer = ask("Are you sure you want to delete #{branch.name} [#{choices}]? ") do |q| q.echo = false q.character = true q.validate = /\A[#{choices}]\Z/ end answer == 'y' end
execute(args, options = {})
click to toggle source
# File lib/toolshed/commands/delete_branch.rb, line 21 def execute(args, options = {}) branch_name = read_user_input("Ticket ID or branch name:", options) self.branch = Toolshed::Git::Branch.new(branch_name: branch_name) if confirm_delete branch.delete(branch_name) else Toolshed.logger.info "Branch '#{branch.name}' was not deleted." end Toolshed.die end
read_user_input(message, options)
click to toggle source
# File lib/toolshed/commands/delete_branch.rb, line 32 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