class GitSnip::CLI

Public Class Methods

help(shell, subcommand = 'snip') click to toggle source
# File lib/git_snip/cli.rb, line 15
def help(shell, subcommand = 'snip')
  command_help(shell, subcommand)
end

Public Instance Methods

snip() click to toggle source
# File lib/git_snip/cli.rb, line 39
def snip
  if opts[:dry_run]
    return dry_run
  end

  if !opts[:force]
    printer.force_option_needed
    exit 64
  end

  cleaner = GitSnip::Cleaner.new(*cleaner_args)

  printer.deleting_branches

  deleted_branches = cleaner.delete_merged_branches do |branch|
    printer.branch_info(branch_row(branch))
    true
  end

  if deleted_branches.empty?
    printer.no_branches_deleted
  else
    printer.done
  end
end

Private Instance Methods

branch_row(branch) click to toggle source
# File lib/git_snip/cli.rb, line 98
def branch_row(branch)
  opts[:full] ? Branch.full_row(branch) : Branch.row(branch)
end
cleaner_args() click to toggle source
# File lib/git_snip/cli.rb, line 86
def cleaner_args
  opts.values_at(:repo, :target, :ignore)
end
dry_run() click to toggle source
# File lib/git_snip/cli.rb, line 68
def dry_run
  cleaner = GitSnip::Cleaner.new(*cleaner_args)

  printer.will_delete_branches

  merged_branches = cleaner.merged_branches

  merged_branches.each do |branch|
    printer.branch_info(branch_row(branch))
  end

  if merged_branches.any?
    printer.done
  else
    printer.no_branches_to_delete
  end
end
opts() click to toggle source
# File lib/git_snip/cli.rb, line 90
def opts
  @opts ||= Options.merge(options, Config.new(options[:repo]).options)
end
printer() click to toggle source
# File lib/git_snip/cli.rb, line 94
def printer
  @printer ||= Printer.new(self)
end